hdu 1018 Big Number (数学题)
2014-04-04 20:59
435 查看
Problem Description
Inmany applications very large integers numbers are required. Some of theseapplications are using keys for secure transmission of data, encryption, etc.In this problem you are given a number, you have to determine the number ofdigits in the
factorial of the number.
Input
Inputconsists of several lines of integer numbers. The first line contains aninteger n, which is the number of cases to be tested, followed by n lines, oneinteger 1 ≤ n ≤ 107 on each line.
Output
Theoutput contains the number of digits in the factorial of the integers appearingin the input.
SampleInput
2
10
20
Sample Output
7
19
/**************************************************
// 不能直接算N!,数据规模 1<N<10^7 太大,超出 2^31 的范围,所以取对数函数
// N = M*10^n n = log10(N) log10() 函数在头文件cmath中
984 MS,差点超时
************************************************/
Inmany applications very large integers numbers are required. Some of theseapplications are using keys for secure transmission of data, encryption, etc.In this problem you are given a number, you have to determine the number ofdigits in the
factorial of the number.
Input
Inputconsists of several lines of integer numbers. The first line contains aninteger n, which is the number of cases to be tested, followed by n lines, oneinteger 1 ≤ n ≤ 107 on each line.
Output
Theoutput contains the number of digits in the factorial of the integers appearingin the input.
SampleInput
2
10
20
Sample Output
7
19
/**************************************************
// 不能直接算N!,数据规模 1<N<10^7 太大,超出 2^31 的范围,所以取对数函数
// N = M*10^n n = log10(N) log10() 函数在头文件cmath中
984 MS,差点超时
************************************************/
#include <iostream> #include<cmath> using namespace std; int main() { double sum; int T,n; cin>>T; while(T--) { cin>>n; sum = 1; for(int i = 1;i<=n;i++) sum+=log10(i); cout<<(int)sum<<endl; } return 0; }
相关文章推荐
- hdu 1018 Big Number(纯数学公式)
- POJ 1423 &&hdu 1018 Big Number【数学】
- HDU 1018-Big Number(数学)
- HDU 1018 Big Number (数的阶乘的长度:数学)
- HDU-1018-Big Number( 这段数学推导我给满分! && 然而并不想用斯特林公式! )
- HDU 1018 Big Number(数学知识)
- HDU 1018 Big Number 数学题
- hdu-1018-Big Number-简单数学
- HDU 1018 Big Number (数学题)
- hdu 1018 Big Number 数学结论
- HDU 1018-Big Number(数学)
- HDU 1018 Big Number (简单数学)
- HDU 1018 Big Number 数学题解
- HDU 1018 Big Number 数学题解
- hdu 1018 Big Number (数学题)
- hdu 1018 Big Number 数学
- hdu 1018 Big Number(纯数学公式)
- Hdu 1018 Big Number
- hdu 1018 Big Number
- hdu_1018_Big Number_求阶乘长度模板题