HDOJ 1018 Big Number
来源:互联网 发布:双色球参选数据真的吗 编辑:程序博客网 时间:2024/06/05 01:58
http://acm.hdu.edu.cn/showproblem.php?pid=1018
该问题要用到斯特林公式: log10(n!) = log10(sqrt(2 * pi * n)) + n * log10(n / e)
一个数的位数=log10(n)+1.
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
2
10
20
Sample Output
7
19
#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<cmath>#define PI 3.1415926 using namespace std;int main(){int a;long long b;int sum;cin>>a;while(a--){cin>>b;int sum=(0.5*log(2.0*PI*b) + b*log((double)b) - b) / log((double)10) + 1;cout<<sum<<endl;}return 0;}
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- HDoj-1018-Big Number
- HDOJ Big Number 1018
- hdoj 1018 big number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- hdoj-1018-Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- 如何清理arp缓存和清除dns缓存
- spring aop实现注解式缓存
- 发布前后版本数值变化
- SSZipArchive的使用详解和遇到的问题
- JavaScript基础内容复习1
- HDOJ 1018 Big Number
- mysql 查询当天当周当月的数据
- 文章标题
- Java 代码编译和执行的整个过程详解
- shell教程六:多行输入 、调试
- Mac OS X 10.11+系统 安装CocoaPods
- 字符流中第一个不重复的字符
- 【ReactJS】自制TreeView控件
- 算法-求二进制数中1的个数