HDU 1018 Big Number

 

有个数学公式计算数的阶乘位数

 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 }

 

posted @ 2016-03-17 22:42  闪耀子  阅读(158)  评论(0编辑  收藏  举报