Big Number

来源:互联网 发布:无钢圈内衣品牌 知乎 编辑:程序博客网 时间:2024/04/30 00:25

Big Number

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 3   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size:  

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

Source

Asia 2002, Dhaka (Bengal)


求阶乘的位数,比方5的阶乘120是3位,输出3
一个数学算法,主要用公式
#include <stdio.h>#include <math.h>#define pi 3.1415926535#define E 2.71828182846long m,n,ss;int main(){    scanf("%d",&n);    while(n--)    {        scanf("%d",&m);        ss=log10(sqrt(2*pi*m))+m*log10(m/E);  //公式        printf("%d\n",ss+1);    }}

原创粉丝点击