[暖手][学习阶段-各路杂题][HDU-1018]Big Number

来源:互联网 发布:无线图像传输 单片机 编辑:程序博客网 时间:2024/04/30 16:36

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
 

import java.util.Scanner;public class Main {public static void main(String[] args) {// TODO Auto-generated method stubScanner in = new Scanner(System.in);int T = in.nextInt();while(T>0){int n = in.nextInt();int len =  (int) (0.5*Math.log10(2*3.1415927*n)+n*Math.log10(n/2.718281828459));System.out.println(len+1);T--;}}}



0 0