HDU1018 Big Number

题目地址: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;
}

你可能感兴趣的:(number)