log10(n!)=log10(2pin)0.5+nlog10(n/e)
注意long long
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #define ll long long #define pi 3.1415926535 #define E 2.718281828459 using namespace std; const int mod=1e9+7; int n,x; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; double s=log10(2*pi*x)*0.5+x*(log10(x/E)); cout<<(long long)(s)+1<<endl; } return 0; }
|