标签:style main define math ack print alt black question
1130 N的阶乘的长度 V2(斯特林近似)(51NOD基础题)
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 1000) 第2 - T + 1行:每行1个数N。(1 <= N <= 10^9)
共T行,输出对应的阶乘的长度。
3 4 5 6
2 3 3
#include <cstdio> #include <cmath> #define LL long long #define PI acos(-1) int main(){ int t ; LL n ; scanf("%d" , &t) ; while(t--){ scanf("%lld" , &n) ; // 注意 给存放 n! 的位数的变量 开long long
// 斯特林近似 公式 LL a = (LL)((0.5*log(2*PI*n) + n*log(n)-n)/log(10)) ; printf("%lld\n" , a + 1 ) ; } return 0 ; }
标签:style main define math ack print alt black question
原文地址:http://www.cnblogs.com/yi-ye-zhi-qiu/p/7553487.html