题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018
题意:给定一个数求此数阶乘结果的位数。
公式:log10(1)+log10(2)+......+log10(n)+1
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
int t;
int main () {
ios::sync_with_stdio(false);
cin>>t;
while(t--) {
int n;
cin>>n;
double ans=0;
for(int i=2;i<=n;i++)
ans+=log10(i);
cout<<(int)ans+1<<endl;
}
return 0;
}