C. C. Blog

Security Research, Algorithm and Data Structure

51Nod 1130 斯特林近似

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;
}
  • 本文作者: CCWUCMCTS
  • 本文链接: https://ccwucmcts.github.io/posts/17812/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!