hdu1018

Big Number

  直接套用stirling数的公式即可。关于strling数,可参考下图

代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x7fffffff
#define pi acos(-1.0)
#define mst(a,b) memset(a,b,sizeof(a))
const double e=2.718281828459;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e6+5;
int ()
{
int t;

cin>>t;
while(t--)
{
double n;
cin>>n;
ll ans=0;
ans=(int)(floor((log10((2*pi*n)))/2+n*log10(n/e))+1); //stirling公式
cout<<ans<<endl;
}
return 0;
}
/**/