F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Lucky Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2078    Accepted Submission(s): 629


Problem Description
¡°Ladies and Gentlemen, It¡¯s show time! ¡±

¡°A thief is a creative artist who takes his prey in style... But a detective is nothing more than a critic, who follows our footsteps...¡±

Love_Kid is crazy about Kaito Kid , he think 3(because 3 is the sum of 1 and 2), 4, 5, 6 are his lucky numbers and all others are not.

Now he finds out a way that he can represent a number through decimal representation in another numeral system to get a number only contain 3, 4, 5, 6.

For example, given a number 19, you can represent it as 34 with base 5, so we can call 5 is a lucky base for number 19.

Now he will give you a long number n(1<=n<=1e12), please help him to find out how many lucky bases for that number.

If there are infinite such base, just print out -1.
 

Input
There are multiply test cases.

The first line contains an integer T(T<=200), indicates the number of cases.

For every test case, there is a number n indicates the number.
 

Output
For each test case, output ¡°Case #k: ¡±first, k is the case number, from 1 to T , then, output a line with one integer, the answer to the query.
 

Sample Input
2 10 19
 

Sample Output
Case #1: 0 Case #2: 1
 

Hint
10 shown in hexadecimal number system is another letter different from ¡®0¡¯-¡®9¡¯, we can represent it as ¡®A¡¯, and you can extend to other cases.
 

Author
UESTC
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:53:40, Gzip enabled