链接:https://www.nowcoder.net/acm/contest/75/A
来源:牛客网
题目描述
夫夫有一天对一个数有多少位数感兴趣,但是他又不想跟凡夫俗子一样,
所以他想知道给一个整数n,求n!的在8进制下的位数是多少位。
输入描述:
第一行是一个整数t(0
#include<cstdio>
#include<cmath>
#define pi acos(-1.0)
int main()
{
double ans;
int t;
double temp = log(8),e=exp(1);
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
ans = ((log(2 * n*pi) / 2) + n*(log(n / e))) / temp + 1;
if (n == 0 || n == 1)printf("1\n");
else printf("%.0lf\n", floor(ans));
}
}