基准时间限制:1 秒 空间限制:131072 KB 分值: 0
难度:基础题
输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。
Input
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 1000) 第2 - T + 1行:每行1个数N。(1 <= N <= 10^9)
Output
共T行,输出对应的阶乘的长度。
Input示例
3 4 5 6
Output示例
2 3 3
代码:
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> #define PI acos(-1) #define e exp(1) #define LL long long using namespace std; int main() { int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); LL ans=0.5*log10(2*PI*n)+n*log10(n/e); printf("%lld\n",ans+1); } return 0; }