poj 1423 Big Number

时间:2014-05-13 22:06:51   收藏:0   阅读:253
bubuko.com,布布扣
 1 /**
 2 斯特林(Stirling)公式:
 3  
bubuko.com,布布扣
 4 求 n! 的位数 
 5 
 6 ceil函数的作用是求不小于给定实数的最小整数。
 7 **/
 8 #include <iostream>
 9 #include <algorithm>
10 #include <cmath>
11 using namespace std;
12 const double pi = acos(-1.0);
13 int main()
14 {
15     int t;
16     cin>>t;
17     double n;
18     while(t--){
19         cin>>n;
20         if(n==1){
21             cout<<1<<endl;
22             continue;
23         }
24         int res = ceil((0.5*log(2*pi*n)+n*log(n)-n)/log(10.0));
25         cout<<res<<endl;
26     }
27     return 0;
28 }
bubuko.com,布布扣

 

poj 1423 Big Number,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!