计算阶乘位数
Problem:26
Time Limit:2000ms
Memory Limit:65536K
Description
根据密码学需要,要计算某些数的阶乘的位数.
Input
第一行为整数n ,接下来 n 行, 每行1个数m (1 ≤ m ≤ 10^7) .
Output
输出m的阶乘的位数.
Sample Input
2 10 20
Sample Output
7 19
Hint
Source
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n,m,sum;double t;
cin>>n;
for(int i=1;i<=n;i++)
{
sum=0;t=0.0;
cin>>m;
for(int j=2;j<=m;j++)
t=t+log10(j);
sum=(int) t+1;
cout<<sum<<endl;
}
return 0;
}