Finding divisors of an integer is common task. We all did it in some time or other during our programming courses. We know that there are several ways to find divisors of an integer N. All of them involve some kind of programming using loops. But what if we ask you to solve the reverse problem?

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.

#include
using namespace std;
int main()
{
int t,Case=1;
cin>>t;
while(t–)
{
int k,x,y,z;
long long int N;
cin>>k;
while(k==2 ? cin>>x>>y : cin>>z)
{
if(k==1)
{
N = z into z;
break;
}
else
{
N = x into y;
break;
}

Does the question specify that it will give repetitive divisors also, like for example for numbers 4,9,25 which have only one unique divisor,this set will contain all the squares of prime numbers.
If it does not then you would have to handle them separately.

Consider a Positive Composite Integer N. Surely, N can be split into two factors, say, (a) and (N/a). Let a be the smallest factor of N, then (N/a) will be the largest factor of N.

It was mentioned in the question that all factors will be listed. So, definitely, a and N/a will be present in the list. Find the smallest and largest in the given list. These are indeed a and (N/a) respectively.

Their product gives the answer. (a \times (N/a) = N)

It can easily be understood by taking the prime factorization of a composite number.
Leave the smallest prime factor and take product of other prime factors that is bound to be the largest factor and the total product is the original number.

Very little information was provided. We don’t have a link to the actual problem. And I think it doesn’t matter whatever way they give the input when our approach is to find min and max of the list.

Say For N = 25.
Type 1:

Input:

1
5

Output:

25
// Because max and min of the list are 5 and 5 respectively.

Yeah the Question is not clear, but as long as the question makes sure that all the proper divisors are given it is fine also for single divisor as both max and min will be at same array index.