版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tju_peter/article/details/79255778
链接:https://www.nowcoder.net/acm/contest/75/A
夫夫有一天对一个数有多少位数感兴趣,但是他又不想跟凡夫俗子一样,
所以他想知道给一个整数n,求n!的在8进制下的位数是多少位。
所以他想知道给一个整数n,求n!的在8进制下的位数是多少位。
斯特林公式,log以8为底。刚开始特判都忘了..........
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
double pi=acos(-1);
int main()
{
int t,n;
double ans;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
ans=(n*log(n) - n + 0.5*log(2*n*pi))/log(8)+1;
if(n<=3) printf("1\n");
else printf("%d\n",(int)ans);
}
return 0;
}