hdoj1018 Big Number

 1 /*
 2  *    digits=lg(n!)+1=lg(1)+lg(2)+...+lg(n)+1
 3  *
 4  *    利用stirling公式化简 lg(n!)=lg( sqrt(2*pie*n) ) + n*lg(n/e)
 5  */
 6 #include <stdio.h>
 7 #include <math.h>
 8 #define  pie acos(-1.0)
 9 #define  e 2.7182818284
10 int main()
11 {
12     int i,j,n,res,t;
13     while(~scanf("%d",&t))
14     {
15         while(t--)
16         {
17              scanf("%d",&n);
18              res=1+ (int)(log10(sqrt(2*pie*n)) + n*log10(n/e));
19              printf("%d\n",res);
20         }
21     }
22     return 0;
23 }
原文地址:https://www.cnblogs.com/symons1992/p/3088521.html