Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:25:07+00:00 2026-06-15T08:25:07+00:00

I am trying to solve one problem from on-line judging system. I have a

  • 0

I am trying to solve one problem from on-line judging system. I have a solution which works, but not efficient enough. Here is the problem:

Which the least number n can we imagine in product n = a∙b like k ways? Products a∙b and b∙a is one of the way, where all numbers is natural (1≤ k ≤50).

Input One number k.
Output One number n.

My code did not pass four tests. It is too slow for k=31, 37, 47. I have been thinking on this problem 2 days,but no improvement. Here is my code, please share, if you have any ideas.

    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>

    int prime[10000];
    long x,j,i,flag,k,length,p,checker,count,number;

    int main()
    {

    prime[0]=2;
    scanf("%ld",&k);
    //I find prime numbers between 1 and 1000. 1000 can be changed, just for testing

    for (i=3;i<=1000;i=i+2)
            {
            flag=0;
            for (j=2;j<=sqrt(i);j++)
                    {
                    if(i%j==0)
                            {
                            flag=1;
                            break;
                            }
                    }
            if(flag==0)
                    {
                    x++;
                    prime[x]=i;
                    }
            }

    length=x;
    //this loop is too big I know, again for testing. I suspect, there must be a way to make some changes to this for loop 

    for (i=1;i<10000000000;i++)
            {
            number=i;
            p=1;
            for(x=0;x<=length;x++)
                    {
                    if(prime[x]>sqrt(i))
                    break;
                    count=0;
                    while(number%prime[x]==0)
                            {
                            number=number/prime[x];
                            count++;       
                            }
                    p=p*(count+1); 
//I find prime factors of numbers and their powers, then calculate number of divisors

                    }
            //printf("%d\n",p);
            //number of ways is just number of divisors/2 or floor (divisors/2)+1
            if(p%2==0)
            checker=p/2;
            else
            checker=floor(p/2)+1;
            if(checker==k)
                    {
                    printf("%ld\n",i);
                    break;
                    }
            }

    return 0;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:25:08+00:00Added an answer on June 15, 2026 at 8:25 am

    If I understand the problem correctly it’s asking you which is the least number n with exactly 2k divisors (should I consider 1 and n?)

    in fact if a number has a divisor a, then n / a = b is an integer and n = a* b (counting only one time a and b, so you should divide by two the number of divisors)

    edit

    Doing that is time consuming indeed. So this is the idea;

    for a number n in the form n = p1^(a1)*p2^(a2)…pn^(an) (this is the prime factorization of the number) the number of divisor is (a1 + 1)(a2+1)…(an+1)

    Hence, if you want to find a number that has k divisor, factorize k. then assign the biggest factor to the smallest prime; eg if k = 2*5*7, then n should be 2^7*3^5*5^2

    I know it is not since i didnt take into account that (a, b) is equal to (b, a) but play around it a little and it should work

    example

    take k = 37. Then double the number – (to consider the symmetry). You get 74.
    Now, if you can imagine n as n = n * 1, then you just need to factor 74 (that is 2 * 37);
    then give 36 to 2 and 1 to 3, leading n = 2^(36)*3 = 206158430208

    if you can’t, then you need to add 1 to the number you got previously (in this case, 74 + 1 = 75 = 25*3); this way you get n = 2^24 * 3^2 = 150994944

    If it’s none of the above, then I am probably wrong…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to C and I'm trying to solve one of the exercise problem
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
I'm trying to solve the following problem in Redis. I have a list that
I am trying to solve this problem http://www.spoj.pl/problems/PEBBMOV/ . I think I have the
I am trying to solve the following problem with Puppet: I have multiple nodes.
i'm trying to extract from proper noun from a tagged file. But the problem
There have been similar posts, but none helped me solve my problem. I am
I am thinking about exploiting parallelism for one problem I am trying to solve.
I am trying to solve a simple Ruby problem from Seven Languages in Seven
I'm trying to solve this problem for a week now and I have tested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.