阅读612 返回首页    go 阿里云 go 技术社区[云栖]


POJ 1423 大数阶乘位数

题意让求一个数m阶乘的位数,可以用sum(log10(1~n))+1打表,也可以用公式

#include <iostream>
#include <math.h>

using namespace std;

const double e= 2.718281828459 ;
const double pi= 3.1415926535898 ;

int main()
{
    long long n,tt;
    cin>>tt;
    while (tt>0)
    {
        tt--;
        cin>>n;
        long long ans = (long long)((double)log10(sqrt(2 * pi * n)) + n * log10(n / e))+1;
        cout<<ans<<endl;
    }
    return 0;
}


最后更新:2017-04-04 07:03:48

  上一篇:go java图片裁切工具类
  下一篇:go Ubuntu adb devices : no permissions 解决方法