首页 > 技术文章 > 数论练习(7)——斯特林公式

cunyusup 2018-02-03 23:52 原文

斯特林公式:

 

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define Pi 3.1415926535
typedef long long  ll;

const int inf = 0x3f3f3f3f;
const int moder = 1e9 + 7;
const int MAXN=1000010;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int ans = log10(2*n*Pi)/2+n*log10(n/exp(1));
        cout << ans+1 << endl;
    }

    return 0;
}

 

推荐阅读