问题3081--A sieries of nine

3081: A sieries of nine

[命题人 : ]
时间限制 : 2.000 sec  内存限制 : 64 MB

题目描述

we know 99%9=0,999999%3=0,but when we get a number L what’s the shortest length sierise of nine that can dive L without reminder.Ie. 9999999……9999%L==0,what is the shortest length?

输入

The input consists of multiple test cases. Each test case contains exactly one line containing L(1 ≤ L ≤ 2,000,000,000). The last test case is followed by a line containing a zero.

输出

For each test case, print a line containing the test case number( beginning with 1) followed by a integer which is the length of the sieries of nine . If we can’t find it print a zero.

样例输入 Copy

1
2
3
99
999
25

样例输出 Copy

Case 1: 1
Case 2: 0
Case 3: 1
Case 4: 2
Case 5: 3
Case 6: 0


提示

In the first case 9%1=0,so the answer if 1 because 9's length is 1 and it is the shortest length.. In the fifth case 999%999=0,so the answer if 3 because 9's length is 3 and it is the shortest length. In the sixth there is no suth number that mod 25 =0,so the answer is 0,as the problem require.

来源/分类