hdu1018(斯特灵公式)
来源:互联网 发布:吉利电动车知豆d1报价 编辑:程序博客网 时间:2024/05/16 11:12
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 27548 Accepted Submission(s): 12526
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
题目大意:求一个数阶乘的位数。
分析:原本以为是一道大数题,其实是一道简单的数学题,需要用到“斯特灵”公式,log(n!)=log1 + log2 + ... + logn。
斯特灵公式链接:http://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E9%9D%88%E5%85%AC%E5%BC%8F
#include <cstdio>#include <cmath>using namespace std;int main (){ int n,m,i; double sum; scanf ("%d",&n); while (n--) { scanf ("%d",&m); sum = 0; for (i=1; i<=m; i++) { sum += log10((double)i); } printf ("%d\n",(int)sum+1); } return 0;}
0 0
- hdu1018(斯特灵公式)
- hdu1018--斯特灵公式
- hdu1018 Big Number(斯特林公式)
- hdu1018(斯特林公式)
- HDU1018(斯特林公式)
- hdu1018——Big Number(大数阶乘,斯特林公式)
- hdu1018 Big Number stirling公式
- POJ1423 HDU1018 Big Number【斯特林公式】【高精度】
- HDU1018 (最小公倍数)
- hdu1018(大水题)
- HDU1018(Big Number)
- hdu1018
- hdu1018
- hdu1018
- hdu1018
- hdu1018
- hdu1018
- hdu1018
- Android dagger2使用
- 又到了入学季,谈谈软件研发的团队建设
- 最短路径—Dijkstra算法和Floyd算法
- java 的 多态机制
- 练练手--求串联电阻的阻值
- hdu1018(斯特灵公式)
- 欢迎使用CSDN-markdown编辑器
- [leetcode-115]Distinct Subsequences(java)
- vector的sort用法
- 安卓学习之路(二):app总览和Activity简介
- 【HDU2389】【二分匹配】【HK算法模板】
- Android怎么获取ListView的值
- hdu2059(dp)
- 员工管理系统(数组)