2013
11-09

# Big Number

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 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.

The output contains the number of digits in the factorial of the integers appearing in the input.

2
10
20

7
19

import java.util.*;

public class Main {

public static void main(String[] args) {
Scanner cin = new Scanner(System.in);

int n = cin.nextInt();
while(n > 0) {
int test = cin.nextInt();
if(test <= 3)
System.out.println(1);
else {
double result = 0.5*Math.log10(2*test*Math.PI)+
test*Math.log10(test/Math.E)+1;;
System.out.println((int)(result));
}
n--;
}
}

}

1. if(j){
int ans=a ;
for(int x=j-1;x>=0;x–){
if(!a ) break;
ans=min(ans,a );
sum+=ans;
}
}
求解释，，dp的思路是什么呢？

2. 5.1处，反了；“上一个操作符的优先级比操作符ch的优先级大，或栈是空的就入栈。”如代码所述，应为“上一个操作符的优先级比操作符ch的优先级小，或栈是空的就入栈。”