HDU-1018- Big Number
来源:互联网 发布:个人手机记工软件 编辑:程序博客网 时间:2024/06/04 18:35
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38518 Accepted Submission(s): 18677
Total Submission(s): 38518 Accepted Submission(s): 18677
Problem Description
In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.
Input
Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 107 on each line.
Output
The output contains the number of digits in the factorial of the integers appearing in the input.
Sample Input
21020
Sample Output
719
Source
Asia 2002, Dhaka (Bengal)
利用公式:(int)log10(n)+1 或
斯特林公式:斯特林公式:lnN!=NlnN-N+0.5*ln(2*N*pi)。
#include<cstdio>#include<cmath>int main(){int T,n;scanf("%d",&T);while(T--){scanf("%d",&n);double sum=0;for(int i=1;i<=n;i++){sum+=log10(i);}printf("%d\n",(int)sum+1);}return 0;}
阅读全文
0 0
- 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
- 判断一个数的位数
- 安卓SQLite
- codeforces406D LCA+凸包
- 学习MarkDown编辑器。不看会后悔
- Python中bool类型转换
- HDU-1018- Big Number
- Codeforces Round #428 (Div. 2) B. Game of the Rows
- docker常用命令
- java带返回值的线程示例,简单方便
- kafka 数据可靠性深度解读
- 面向对象的23种设计模式
- [日推荐] 『美女hold住』你要的美女图,这都有,你懂的 !
- 在Ubuntu16.04中安装MySQL
- JDBC学习