输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。
Input
输入N(1 <= N <= 10^6)
Output
输出N的阶乘的长度
Sample Input
6
Sample Output
Input
输入N(1 <= N <= 10^6)
Output
输出N的阶乘的长度
Sample Input
6
Sample Output
3
斯特林公式
n的阶乘长度=0.5*log10(2*PI*n)+n*log10(n/e)+1;(不包含n==1的情况)
#include<stdio.h>
#include<math.h>
#define e 2.718281828459
#define PI acos(-1.0)
#define ll long long
int main()
{
ll T,n,ans;
while(scanf("%lld",&n)!=EOF)
{
if(n==1)
{
printf("1\n");
continue;
}
ans=0.5*log10(2*PI*n)+n*log10(n/e)+1;
printf("%lld\n",ans);
}