题目链接: 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 就好了啦~
代码:
1 #include <bits/stdc++.h>
2 using namespace std;
3
4 const double pi= M_PI;
5 const double e=M_E;
6
7 int main(void){
8 int t;
9 scanf("%d", &t);
10 while(t--){
11 int x;
12 scanf("%d", &x);
13 if(x==1){
14 printf("1
");
15 continue;
16 }
17 long long gg=(log10(2*pi)+log10(x))/2+x*(log10(x)-log10(e));
18 printf("%lld
", gg+1);
19 }
20 return 0;
21 }