You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 12…*N. For example, 5! = 120, 120 contains one zero on the trail.
Time Limit: 2 second(s)
Memory Limit: 32 MB
Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.
Each case contains an integer Q (1 ≤ Q ≤ 10^8) in a line.
Output
For each case, print the case number and N. If no solution is found then print ‘impossible’.
Sample Input
3
1
2
5
Output for Sample Input
Case 1: 5
Case 2: 10
Case 3: impossible
Code
1 | import java.util.Scanner; |