You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
676 B

2 years ago
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
/*
log10(x)
*/
const int N = 10000010;
int a[N];
int main() {
//预处理出阶乘的位数
double x = 0;
for (int i = 1; i < N; i++) {
x += log10((double)i); // POJ对于log10(i)会报编译错误需要转为double
a[i] = x + 1;
}
// T次询问
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
printf("%d\n", a[n]);
}
return 0;
}