且未

博客园 首页 新随笔 联系 订阅 管理
#include<iostream>
#include <cstdio>
#include <cmath>
using namespace std;

const double PI =acos(-1.0);
const double  e = 2.71828182;

int main()
{
    double ans,res;
    int n;
    //斯特林定理求N!的位数
    cin>>n;
    ans = 1.0/2*log10(2*PI*n)+n*log10(n/e);;
    cout<<(int)ans+1<<endl;
      //log求N!的位数
    res=1;
    for(int i=1;i<=n;i++)
    res += log10((double)i);
    printf("%d\n",(int)res);
    return 0;
}

 

posted on 2018-11-30 14:03  阿聊  阅读(199)  评论(0编辑  收藏  举报