题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1018
网上有求解的数学公式,
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
int caseNum,i,j,n,count;
double sum;
while (cin>>caseNum)
{
for (i=0;i<caseNum;++i)
{
cin>>n;
sum = 0.0f;
count = 0;
for (j=1;j<=n;++j)
{
sum +=log10f(static_cast<float>(j));
}
cout<<static_cast<int>(sum)+1<<endl;
}
}
return 0;
}
本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/01/04/1026347.html,如需转载请自行联系原作者