poj - 1423-Big number

来源:互联网 发布:Ping应用的端口号 编辑:程序博客网 时间:2024/05/17 01:44


H - Big Number
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 1423

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

21020

Sample Output

719

代码:

#include <cstdio>#include <cmath>#include <iostream>using namespace std;int a[10000001];int main() {int n, i, cas;double s;for(i = 1,s = 0;i <= 10000000; i ++) {s += log10((double)i);a[i] = (int)s + 1;}scanf("%d", &cas);while (cas --) {scanf("%d", &n);printf("%d\n", a[n]);}return 0;}


原创粉丝点击