poj 1423 Big Number

 1 /**
 2 斯特林(Stirling)公式:
 3  

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 }
原文地址:https://www.cnblogs.com/Bang-cansee/p/3724118.html