1058 N的阶乘的长度
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注
输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。
Input
输入N(1 <= N <= 10^6)
Output
输出N的阶乘的长度
Input示例
6
Output示例
3
n!的长度等于log10(n!)
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double ans=1;
int n;
cin>>n;
for (int i=1;i<=n;i++)
ans+=log10(i);
cout<<(long)(ans);
return 0;
}
216

被折叠的 条评论
为什么被折叠?



