Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 52992 Accepted Submission(s): 26078
Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.InputInput consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 107 on each line.OutputThe output contains the number of digits in the factorial of the integers appearing in the input.Sample Input21020Sample Output719
求数字的位数可以用log10()函数来实现
log10()是一个cmath头文件里的函数 double log10(double x) 对数函数(10为底数)
数字位数=(int)log10(num)+1
放下代码!
这题记得要打表 不然会超时
#include<iostream>
#include<cmath>
int a[10000005];
int main()
{
using namespace std;
int T;
__int64 x;
double result=0;
for(int i=1;i<=10000002;++i)
{
result+=log10(i);
a[i]=(int)result+1;
}
cin>>T;
while(T--)
{
result=0;
cin>>x;
cout<<a[x]<<endl;
}
}