n!的位数 斯特林公式

#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define ll long long int
#define eps 0.0001
#define fo1(s,e) for(ll i=s;i<=e;i++)
#define fo2(s,e) for(ll j=s;j<=e;j++)
#define mem(a,n) memset(a,n,sizeof(a))
#define mod 1000000009
#define maxn 505
#define inf 0x3f3f3f3f3f3f3f3f 
using namespace std;
#define PI acos(-1)
#define E exp(1.0)
int main(){
    ll n,t;
    cin>>t;
    while(t--){
        long long ans=1;
        cin>>n;
        if(n>3){
            ans = log10(sqrt((long double)2.0 * PI*n))+(n*(log10((long double)n)-log10((long double)E)))+1;
            //cout << log10(sqrt(2 * PI*n)) + ((n*log10(n / E))) << endl;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

 

posted @ 2017-10-27 14:25  Luke_Ye  阅读(702)  评论(0编辑  收藏  举报