Question Link
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1215
The question should be slightly changed. It is too difficult to think about it. If you have an idea, you can try it to make progress,
At first, I directly sought the factor, sum, and undoubtedly timed out. When is the question so easy? Obviously not,
Flexible. Just a little bit, you can use AC. Everything is in the code.
Code timeout
# Include <stdio. h>
Int main (void)
{
Int t, n, I, J, K, L;
Scanf ("% d", & T );
While (t --)
{
Scanf ("% d", & N );
Int S = 0;
K = n/2;
For (I = 1; I <= K; I ++)
If (N % I = 0)
S = S + I;
Printf ("% d \ n", S );
}
Return 0;
}
AC code
# Include <stdio. h>
# Include <math. h>
Int main (void)
{
Int t, n, I, J, K, L;
Scanf ("% d", & T );
While (t --)
{
Scanf ("% d", & N );
If (n = 1)
{
Printf ("0 \ n ");
Continue;
}
K = SQRT (N );
Int S = 0;
For (I = 2; I <= K; I ++)
{
L = N/I;
If (N % I = 0)
{
If (I! = L)
S = S + I + L;
Else
S = S + I;
}
}
Printf ("% d \ n", S + 1 );
}
Return 0;
}
HDU-1215-Qixi Festival