hdu——Big Number

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 ≤ 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
`21020`

Sample Output
```719

题目是要求出n!的位数，用到了斯特林数：

log10(n!)=1.0/2*log10(2*pi*n)+n*log10(n/e)

分析：

#include

#include

const double PI=3.14159265;using namespace std;int main(){
int t,n;
double sum;
cin>>t;
while(t--)
{
cin>>n;
sum=(n*log(n) - n + 0.5*log(2*n*PI))/log(10)+1;
cout<<(int)sum<

}
return 0;}

```

#### 最新留言

[***.36.148.179]2022年06月18日 11时40分08秒

## 关于作者

喝酒易醉，品茶养心，人生如梦，品茶悟道，何以解忧？唯有杜康！
-- 愿君每日到此一游！