求N!的长度数学 51nod 1058

Posted zhwong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求N!的长度数学 51nod 1058相关的知识,希望对你有一定的参考价值。

n!的长度等于log10(n!)

1
2
3
4
5
6
7
8
9
10
11
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    double ans = 1;
    for(int i = 1; i <= n; i++) {
        ans += log10(i);
    }
    cout << (int)ans << endl;
}

以上是关于求N!的长度数学 51nod 1058的主要内容,如果未能解决你的问题,请参考以下文章