判断一个数n的位数 :位数= (int)log10(n)+1
那么n的阶乘的位数就是: (int)log10(1)+(int)log10(2)+(int)log10(3)+...+(int)log10(n)+1
ACd代码:
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
long long int x;
cin >> x;
double sum = 0;
for (int i = 1; i <=x; i++)
{
sum += log10(i);
}
cout << (int)sum + 1 << endl;
}
return 0;
}