HDU 1018 Big Number
来源:互联网 发布:淘宝首页的广告费 编辑:程序博客网 时间:2024/05/17 05:05
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24016 Accepted Submission(s): 10884
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
注意:一个数x的位数等于用(int)log10(x)+1,所以x=n! 的位数即为log10(x)也就是log10(i) (1<=i<=n)整数部分+1.
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>int gao(int num){double ans = 0;int i;for(i=2;i<=num;++i){ans += log10(i*1.0);}return ans;}int main(){int n,num,res;scanf("%d",&n);while(n--){scanf("%d",&num);res = gao(num);printf("%d\n",res+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
- 浅析移动互联浪潮之由来
- ubuntu解压zip文件乱码问题
- 中国炼油厂加工2月创纪录的生产原油1050万桶
- hive中简单介绍分区表
- 【Android UI设计与开发】第03期:引导界面(三)仿微信引导界面以及动画效果
- HDU 1018 Big Number
- 编译原理(开始)
- HDU 1036 Average is not Fast Enough!
- 马丁蒙托亚将继续为巴萨www.yishengbo23.com
- 澳元兑美元将成为中国经济放缓对冲目标www.yishengbo23.com
- 本地缓存的使用
- Java中重载和重写的区别
- android 项目中出现红色感叹号的解决方法
- 用lingo解决易拉罐下料问题