斯特斯特林近似(n!的位数)

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<string.h>
 4 #include<math.h>
 5 #include<algorithm>
 6 #include<queue>
 7 #include<stack>
 8 #include<deque>
 9 #include<iostream>
10 using namespace std;
11 typedef long long  LL;
12 const double pi=acos(-1.0);
13 const double e=exp(1);
14 
15 int main()
16 {
17     LL i,n,x,ans,t;
18     scanf("%lld",&t);
19     for(i=1;i<=t;i++)
20     {
21         scanf("%d",&n);
22 
23         ans=ceil(log10(sqrt(2*pi*n))+n*log10(n/e));
24 
25         printf("%lld
",ans);
26     }
27     return 0;
28 }
原文地址:https://www.cnblogs.com/daybreaking/p/12778809.html