The first is the solution to violence. Note that it is not the essence of violence, but relative violence:
F (n) = log10 (1*2*3*4 *...... * N) + 1 = log10 (1) + log10 (2) + log10 (3) + ...... Log10 (n) + 1.
The result is 406 Ms AC
# Include <iostream>
# Include <cmath>
Using namespace STD;
Int main (){
Int N, num, I;
Double result;
For (scanf ("% d", & N); N; -- N ){
Scanf ("% d", & num );
Result = 1;
For (I = 1; I <= num; ++ I)
Result + = log10 (double (I ));
Printf ("% d/N", INT (result ));
}
Return 0;
}
Second:
Stirling theorem: http://baike.baidu.com/view/2019233.htm? Fr = ala0_1
N! = SQRT (2 * π * n) * (n/E) ^ N)
Obtain the formula log10 (N !) = Log10 (SQRT (2 * pI * n) + N * log10 (N/E) + 11
# Include <cstdio>
# Include <cmath>
Const double Pi = ACOs (-1.0), E = exp (1.0 );
Int main ()
{
Int t, n;
Scanf ("% d", & T );
While (t --)
{
Scanf ("% d", & N );
Printf ("% d/N", (INT) (log10 (SQRT (2 * pI * n) + N * log10 (N/E) + 1 );
}
Return 0;
}