输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。
Input
输入N(1 <= N <= 10^6)
Output
输出N的阶乘的长度
Input示例
6
Output示例
3
点击打开链接这篇博客里讲解了斯特林公式的用法
斯特林公式可以用来估算某数的大小,结合lg可以估算某数的位数,或者可以估算某数的阶乘是另一个数的倍数。
#include <iostream>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
#define pi 3.1415926535898
#define e 2.718281828459
int n;
int main()
{
ios::sync_with_stdio(false); //加快读取速度
cin>>n;
cout<<int((log10(2*pi*n)/2)+(n*(log10(n/e))))+1; //公式
return 0;
}