不要过于沉溺过去,也不要过于畅想未来,把握现在!

POJ 1423

Big Number
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 25714 Accepted: 8229

Description
In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.

Input
Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 <= m <= 10^7 on each line.

Output
The output contains the number of digits in the factorial of the integers appearing in the input.

Sample Input

2
10
20

Sample Output

7
19

Source
Dhaka 2002

<span style="color:#000099;">#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
double sum;
int n,t;
int ans[10000007];
int main()
{
  memset(ans,0,sizeof(ans));
  ans[1]=1;
  for(int i=2;i<10000001;i++)
  {
   sum+=log10(1.0*i);
   ans[i]=(int)sum+1;
  }
  scanf("%d",&n);
  while(n--)
  { sum=0;
   scanf("%d",&t);
   printf("%d\n",ans[t]);}</span>
   return 0;
}


posted @ 2014-09-10 22:45  coding_yuan  阅读(116)  评论(0编辑  收藏  举报

不要过于沉溺过去,也不要过于畅想未来,把握现在!