Big Number
Time Limit:1000MS |
|
Memory Limit:65536K |
Total Submissions:17518 |
|
Accepted:5541 |
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 <= m <= 10^7 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
我们知道整数n的位数的计算方法为:log10(n)+1
故n!的位数为log10(n!)+1
由于这是高精度没法用普通方式计算阶乘,否则会TLE
可以用斯特林(Stirling)公式求解
于是求n!的位数就是求log10((2*PI*n)^1/2*(n/e)^n)+1
即 1/2*log10(2*PI*n)+n*log10(n/e)+1
分享到:
相关推荐
poj 1001答案
北大POJ1019-Number Sequence 解题报告+AC代码
poj 1663 Number Steps.md
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 ) and n is an integer such that 0 输入说明 The input will consist of a set of pairs of...
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
北大POJ2031-Building a Space Station【Prim+计算几何】 POJ2031-Building a Space Station【Prim+计算几何】
D_(POJ_1723)(思维)(第k大数).cpp
POJ第1861题源码 POJ第1861题源码 POJ第1861题源码
poj分类poj分类poj分类poj分类
北大POJ初级-计算几何学 解题报告+AC代码
北大POJ1159-Palindrome 解题报告+AC代码
poj 3414解题报告poj 3414解题报告poj 3414解题报告poj 3414解题报告
poj 1012解题报告poj 1012解题报告poj 1012解题报告poj 1012解题报告
poj 2329解题报告poj 2329解题报告poj 2329解题报告poj 2329解题报告
poj 1659解题报告poj 1659解题报告poj 1659解题报告poj 1659解题报告
C语言 poj npu 西工大 C语言Poj答案全完整打包,给有需要的朋友
http://poj.grids.cn/problem?id=2774 POJ 2774 木棒加工 木材厂有一些原木,现在想把这些木头切割成一些长度相同的小段木头,需要...当然,我们希望得到的小段越长越好,你的任务是计算能够得到的小段木头的最大长度。
POJ1503解答 POJ1503解答,正确答案(已通过POJ)
POJ1083的代码,POJ1083的代码,POJ1083的代码