POJ1423( 数学公式)

大数题!有公式!判断阶乘位数!   

#include <stdio.h>
    #include <math.h>
    const double e=2.718281828459;
    const double pi=3.141582626535;

    double f(int n)
    {
        return n*(log10(n)-log10(e))+0.5*(log10(2)+log10(n)+log10(pi));
    }

    int main()
    {
        int t,m,s;
        scanf("%d",&t);
        while (t--)
        {
            scanf("%d",&m);
            s=(int)f(m)+1;
            printf("%d\n",s);
        }
        return 0;
    }

posted @ 2013-03-26 20:57  algorithms爱好者  阅读(132)  评论(0)    收藏  举报