提示: 欢迎访问OurACM平台。
Problem 1848 ZeroZeroZeros

Accept: 87    Submit: 402
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

As we know n!=1*2*3*…*n, but n! could be extreme huge. For example when n=100 then n! is nearly 9.3*10^157.But now your task is not to calculate the exact value of n! .

Given two kind of operation

operation _A Q

operation _B Q

The operation _A is to calculate the number of rightmost Zeros in Q!. For Example, the number of rightmost zero in 5! (=120) is 1 and the number of rightmost Zeros in 10! (= 3628800) is 2. Note that the number of rightmost Zeros in 23! (= 25852016738884976640000) is 4.

The operation _B is to calculate the smallest number X such that the number of rightmost zero in X! is exactly Q. For example, the smallest number such that the number of rightmost zero in X! is exactly 1 is 5(because 5!=120). The smallest number such that the number of rightmost zero in X! is exactly 2 is 10(because 10!= 3628800).

Input

There are several test cases.

For each case, there are two integers OP, Q in a single line. (1<=OP<=2, 0<=Q<=10^9)

Output

Output a line indicates the case index (start from 1.) with format “Case index:” in a single line.

If OP=1 then output a single line indicates the zeros in the rightmost of Q!.

If OP=2 then output a single line indicates the smallest number X that the number of the rightmost zero in X! is exactly Q.
Output “No solution” (without quotes) in a single line if you could not find such X.

Sample Input

1 5 1 10 2 1 2 2

Sample Output

Case 1: 1 Case 2: 2 Case 3: 5 Case 4: 10

Source

FOJ有奖月赛-2009年10月——稚鹰翱翔

Submit  Back  Status  Discuss