Big Number

题目连接:http://bak2.vjudge.net/contest/137185#problem/A

大意是求n!有多少位。求n的位数等于[log10(n)]+1;n!用斯特灵公式。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi=3.1415926;
const double e=2.7182818;
int main()
{
    int t,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        int m;
        m=int(log10(sqrt(2*pi*n))+n*log10(n/e));
        printf("%d\n",m+1);
    }
    return 0;
}

 

posted @ 2016-10-19 19:34  Twsc  阅读(153)  评论(0编辑  收藏  举报