1542 - Seven little Man

Time Limit : 10 Second

Memory Limit : 128 MB

Submission: 20

Solved: 1

Description
yy is tired of writing the story of seven little man, so, lucky you, solving the following problem is enough.

Given n and k, find max{I | k^i % n! = 0}
Input
The first line contains a single integer T, indicating the number of test cases.

Each test case contains two integers, N and K. 

Output
For each test case, output the case number first, then the answer, if the answer is bigger than 9 223 372 036 854 775 807, output “inf” (without quote).

sample input
2
2 2
10 10
sample output
Case 1: 1
Case 2: 2
hint
1. 1 <= T <= 500
2. 1 <= K <= 1 000 000 000 000 00
3. 1 <= N <= 1 000 000 000 000000 000
source
“恒生杯”网络预选赛 | 非原创
© 2015 HUST ACMICPC TEAM. All Right Reserved.