NYOJ69-数的长度

 1 #include<stdio.h>
 2 #include<math.h>
 3 int main()
 4 {
 5     int i,j,k;
 6     double sum;
 7     int  n,N;
 8     scanf("%d",&n);
 9     while(n--)
10     {
11         sum=0;
12         scanf("%d",&N);//log10(N!)=log10(1)+log10(2)+log10(3)+.....+log10(N);
13         for(j=1;j<=N;j++)
14         sum+=log10(j);
15         k=(int)sum+1;
16         printf("%d\n",k);
17     }
18     return 0;
19 }

posted on 2012-08-02 16:29  mycapple  阅读(168)  评论(0编辑  收藏  举报

导航