In 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.
Input
Input 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 ≤ 10 7 on each line.
Output
The output contains the number of digits in the factorial of the integers appearing in the input.
Sample Input
2
10
20
Sample Output
7
19
题意:输入一个数字,计算n!%10,即为计算阶乘的最后一位数字
思路:列举,取常用对数10为底,累加之后+1即可。
#include <iostream>
#include<cmath>
using namespace std;
int main(){
int n,t;
cin>>t;
while(t--){
cin>>n;
double s=0;
for(int i=1;i<=n;i++)
s+=log10(i);
cout<<(int)s+1<<endl;
}
}