HDU 1018

简介: #include #include #define PI 3.14159265 int num,ans; void count_factorial() { double t; t = (num*log(num) - num + 0.
#include<stdio.h>
#include<math.h>
#define PI 3.14159265
int num,ans;
void count_factorial()
{
    double t;
    t = (num*log(num) - num + 0.5*log(2*num*PI))/log(10);
    ans= (int)t+1;
    printf("%d\n",ans);
}
int main()
{
    int i,n;
    scanf("%d",&n);
    for( i=1 ; i<=n ; i++ )  
    {
        scanf("%d",&num);
        count_factorial();
    }
    return 0;
}





//c++编译错误,g++就ac 
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int i,j,k,T;
    cin>>T;
    while(T--)
    {
        int num;
        cin>>num;
        double sum = 0.0;
        for(i=1;i<=num;i++)
            sum += log10(i);
        int ans =(int)sum+1;
        cout<<ans<<endl;
    }
    return 0;
}
            

 

目录
相关文章
|
7月前
|
Java
hdu-2546-饭卡
hdu-2546-饭卡
32 0
|
Java
hdu 2503 a/b + c/d
hdu 2503 a/b + c/d
47 0
畅通工程 HDU - 1232
畅通工程 HDU - 1232
83 0
HDU 2669 Romantic
题意:找出最小的非负整数X,使之满足式子X*a + Y*b = 1。
113 0