This question is N! The number of zeros that follow. Note that N may be up to 9 times of 10. Haha, how many 2 and 5 factors can be enumerated directly for 1-N, and then a small value will definitely time out.
However, I tried again and time out.
Then we can only draw a mathematical conclusion, and think of N/2 numbers that can be divisible by 2 in 1-N. Haha, think about it later and find that there are N/4 numbers that can be divisible by 4 in 1-N.
That is, N/8, until a certain time of N divided by 2 is 0, then all the values are the number of two factors. This is also the method for finding the number of factors in step 5.
Obviously, the number of 5 factors must be smaller than or equal to the number of 2 factors. Then, you can directly calculate the number of five factors. Because, N/5 is used to take down an integer,
Therefore, we cannot use the Sum Formula of the proportional series. We do not know how to make the answer into a formula.
PS: Actually, my idea is inspired by the method of filtering prime numbers.
The Code is as follows:
# Include <stdio. h>
# Include <algorithm>
# Include <math. h>
Using namespace std;
Int GetAns (int nN)
{
Int nAns = 0;
While (nN)
{
NAns + = nN/5;
NN/= 5;
}
Return nAns;
}
Int main ()
{
Int nT;
Scanf ("% d", & nT );
While (nT --)
{
Int nN;
Scanf ("% d", & nN );
Printf ("% d \ n", GetAns (nN ));
}
Return 0;
}