gavanwanggw

导航

hdu1018--斯特灵公式

斯特灵公式 Wiki http://zh.wikipedia.org/wiki/斯特林公式


/** \brief hdu 1018
 *
 * \param date 2014/7/24
 * \param state AC
 * \return
 *
 */

#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

const double PI=3.1415926;

int main()
{
    //cout << "Hello world!" << endl;
    //freopen("input.txt","r",stdin);
    int t;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        int digits=(int)((0.5*log(2*PI*n)+n*log(n)-n)/log(10));
        cout<<digits+1<<endl;
    }
    return 0;
}


posted on 2017-05-20 20:09  gavanwanggw  阅读(116)  评论(0编辑  收藏  举报