原题:https://www.luogu.com.cn/problem/UVA1185
本题用到的定理的证明:https://www.cnblogs.com/weiliuyby/p/5831991.html
题目:
给出n,求n!的位数
从网上找到了这个公式来求答案
注意多组数据哟!!!
#include<iostream>
#include<cmath>
using namespace std;
long double ln10[10000001];
int n;
int main()
{
cin >> n;
for(int i=1;i<=n;i++)
{
int fact;
cin >> fact;
if(fact==1)
{
cout << "1" << endl;
continue;
}
long double ans=0.00;
for(int i=1;i<=fact;i++)
{
ans+=log10(i);
}
long long answer=ceil(ans);
cout << answer << endl;
}
return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)