https://vjudge.net/problem/HDU-1018#author=0
利用斯特灵数公式计算,复杂度o(1)
直接利用n的位数等于log10(n)+1,复杂度0(n)
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#pragma warning(disable:4996)
using namespace std;
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
double ans = 0;
scanf("%d", &n);
for (int i = 2; i <= n; i++)
ans += log10(i);
cout << int(ans) + 1 << endl;
}
}