LOVELY_BOY_'s blog

By LOVELY_BOY_, history, 3 years ago, In English

I have problem , this might be a silly problem for some people but plz. tell me how to solve this problem. NOTED:I am not asking anything related to any ongoing contest.

the problem statement is: Given all the proper (all the divisors except 1 and N) positive divisors of a positive composite integer N, you need to find the value of N. You should assume that the divisors will be given in such a way so that the value of N will always be greater than 1 and less than or equal to 10^12.

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 7   Vote: I like it +12 Vote: I do not like it
solution

sorry for my poor english

if this helped you plz downvote this comment

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I guess this is a question from the ICPC Kanpur/Mathura Practice round which was held today.

To solve this you need to find LCM of all the numbers. You may refer here.

There was a edge case that if the LCM equals the maximum element, then you need to multiply your LCM with the lowest number from the array.

Here is the code

»
3 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

We can distinguish two cases:

  • $$$N$$$ is a power of a prime (i.e: $$$p^k$$$ for some prime $$$p$$$ and some positive integer $$$k$$$): This case is only possible if all the given numbers are the powers of $$$p$$$ less than $$$p^k$$$. So, to distinguish this case, you can sort all the numbers, check that the first one is a prime and then check that each new number is the current one times the first number. In this case the answer would be the maximum number (it would be $$$p^{k-1}$$$) times $$$p$$$.

  • $$$N$$$ is the product of two or more powers of different primes: In this case, each of those powers is less than $$$N$$$, therefore they will be part of the input. So, for this case, for each prime number keep the biggest power of it given in the input, and then the answer would be the product of all these biggest powers.