51nod1130(斯特林近似)

时间:2023-03-09 23:48:54
51nod1130(斯特林近似)

题目链接: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1130

题意: 中文题诶~

思路:

直接斯特林公式就好了~

N!=sqrt(2*pi*N)*(N/e)^N;(pi=3.1415926=acos(-1.0),e=2.718)
lgN!=(lg(2*pi)+lgN)/2+N*(lgN-lge);

本题求十进制长度, 将 lg 换成 log10 就好了啦~

代码:

 #include <bits/stdc++.h>
using namespace std; const double pi= M_PI;
const double e=M_E; int main(void){
int t;
scanf("%d", &t);
while(t--){
int x;
scanf("%d", &x);
if(x==){
printf("1\n");
continue;
}
long long gg=(log10(*pi)+log10(x))/+x*(log10(x)-log10(e));
printf("%lld\n", gg+);
}
return ;
}