标签:
有个数学公式计算数的阶乘位数
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include<cmath> 5 #define pi 3.141592653 6 #define E 2.718281828 7 using namespace std; 8 9 int main() 10 { 11 12 freopen("C:\\Users\\super\\Documents\\CB_codes\\in.txt", "r", stdin); 13 //freopen("C:\\Users\\super\\Documents\\CB_codes\\out.txt","w",stdout); 14 int n; 15 double t; 16 scanf("%d", &n); 17 while(n -- ) { 18 scanf("%lf", &t); 19 int fac; 20 t = log10( sqrt( 2.0 * pi * t) ) + t * log10( t / E ); //数学公式 21 fac = t; 22 if( t > fac) { 23 fac ++; 24 } 25 printf("%d\n", fac); 26 } 27 28 fclose(stdin); 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/livelihao/p/5289811.html