微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

[暖手][学习阶段-各路杂题][HDU-1018]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
  
  
2 10 20
 

Sample Output
  
  
7 19
 

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// Todo Auto-generated method stub
		Scanner 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--;
		}
		}
	}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐