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.
|
|
|
|
#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;
|
|
|
|
|
}
|