斯特林公式(计算大数阶乘)

#include <iostream>
#include <cstdio>
#include <cmath>
#define PI 3.1415926535898
#define e 2.718281828459
using namespace std;
///斯特林
///n!=sqrt(2*PI*n)*pow(n/e,n)
int main()
{
    int n;cin>>n;
    while(n--){
        long long m;
        scanf("%lld",&m);
        int len=ceil(log10((double)sqrt(2*PI*m))+m*(log10((double)m/e)));
        cout<<len<<endl;
    }
    return 0;
}

 

posted @ 2014-04-30 23:30  xzenith  阅读(604)  评论(0编辑  收藏  举报