51Nod1130斯特林近似
作者:互联网
log10(n!)=log10(2*pi*n)*0.5+n*log10(n/e)
注意long long
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<cmath> 6 #define ll long long 7 #define pi 3.1415926535 8 #define E 2.718281828459 9 using namespace std; 10 const int mod=1e9+7; 11 int n,x; 12 int main(){ 13 cin>>n; 14 for(int i=1;i<=n;i++){ 15 cin>>x; 16 double s=log10(2*pi*x)*0.5+x*(log10(x/E)); 17 cout<<(long long)(s)+1<<endl; 18 } 19 return 0; 20 }
标签:pi,51Nod1130,斯特林,近似,long,int,include,log10,define 来源: https://www.cnblogs.com/sz-wcc/p/10446266.html