It is easy to calculate the number of factors. Calculate the number of each qualitative factor, and then combine the mathematical solutions.
The following is an online download... I thought it was all written in this way...
- /*************************************** ***********
- First, we know that X and Y are all numbers greater than N.
- Suppose y = N + K (k> = 1)
- Take 1/x + 1/y = 1/N and obtain x = N * (N + k)/K-> X = n ^ 2/K + n
- X is an integer, so we only need to know the number of K whose N * n/K is an integer (K is definitely less than N)
- That is, the number of factors in N * n ....
- Each number can be divided into n = p1 ^ E1 * P2 ^ e2 * P3 ^ E3. PR ^ er P1.... PR is a prime number smaller than N.
- The number of factors is num = (1 + E1) * (1 + e2) * (1 + E3) *... * (1 + Er)
- So the number of N * n factors is CNT = (1 + 2 * E1) * (1 + 2 * E2) *... * (1 + 2 * er)
- **************************************** ***********/
/*
To be honest, this question is very good. You must learn to translate it into a mathematical question to explain it ..
*/
# Include <iostream>
# Include <cmath>
Using namespace STD;
# Define Manx 100000
Bool s [Manx];
Int P [Manx], num;
Int prime (){
For (INT I = 0; I <= Manx; I ++)
S [I] = 0;
For (INT I = 2; I <= (INT) SQRT (double) Manx); I ++ ){
If (! S [I]) {
For (Int J = 2; j * I <= Manx; j ++)
S [I * j] = 1;
}
}
Num = 1;
For (INT I = 2; I <Manx; I ++)
If (! S [I]) P [num ++] = I;
}
Int main (){
Prime ();
Int t, n, x [500]; // Number of retention quality factors
Scanf ("% d", & T );
For (int ii = 1; II <= T; II ++ ){
Scanf ("% d", & N );
Memset (x, 0, sizeof (x ));
Int flag = 0;
For (INT I = 1; I <num & P [I] <= N; I ++ ){
Int J = 0;
While (N % P [I] = 0) {// calculate the number of each Prime Factor
X [flag] ++;
N/= P [I];
J = 1;
}
If (j) Flag ++;
}
Int sum = 1;
For (INT I = 0; I <flag; I ++) {// calculate the number of N * n Factors
Sum * = (X [I] * 2 + 1 );
}
If (n> 1) sum * = 3; // This n must be a prime number and must be calculated ..
Printf ("Scenario # % d: \ n", ii );
Printf ("% d \ n", sum/2 + 1 );
}
}