zoukankan      html  css  js  c++  java
  • 51Nod1130斯特林近似

    log10(n!)=log10(2*pi*n)*0.5+n*log10(n/e)

    注意long long

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<string>
     5 #include<cmath>
     6 #define ll long long
     7 #define pi 3.1415926535
     8 #define E 2.718281828459
     9 using namespace std;
    10 const int mod=1e9+7;
    11 int n,x;
    12 int main(){
    13     cin>>n;
    14     for(int i=1;i<=n;i++){
    15         cin>>x;
    16         double s=log10(2*pi*x)*0.5+x*(log10(x/E));
    17         cout<<(long long)(s)+1<<endl;
    18     }
    19     return 0;
    20 }
  • 相关阅读:
    【bzoj1010】[HNOI2008]玩具装箱toy
    bzoj 3173
    bzoj 1179
    bzoj 2427
    bzoj 1051
    bzoj 1877
    bzoj 1066
    bzoj 2127
    bzoj 1412
    bzoj 3438
  • 原文地址:https://www.cnblogs.com/sz-wcc/p/10446266.html
Copyright © 2011-2022 走看看