시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB44201642.105%

문제

Dora loves impressing her friends with number tricks. One of her favorite tricks is to let them name a number n. Dora will then tell them, how many zeroes there are at the end of n!. Usually, Dora’s friends are very impressed because n! is such a large number. For example, if n is 100, even though n! is bigger than the estimated number of atoms in the universe (not counting parallel universes, though), Dora can quickly tell that n! ends with exactly 24 zeroes.

However, some of Dora’s newest friends are aliens with more or less than 10 fingers (or however you call the corresponding parts of their bodies). Like all life forms she has met so far, they count in a number system that has as many digits as they have fingers (even the centipedes from planet Millennium!). Dora wants to impress them as well, but she is not sure how to adapt her trick. Can you help her?

Given a base b and a number n, you should compute how many zeroes there are at the end of n! when written in base b. For example, consider b = 2 and n = 5. Since 5! = 120 = 11110002, the answer is three.

입력

The first line contains the number of scenarios. For each scenario, the input will consist of one line containing the two numbers b (2 ≤ b ≤ 1 000) and n (1 ≤ n ≤ 1 000 000), both given in base ten.

출력

The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario starting at 1. Then print a single line containing (in base ten) k, the number of zeroes at the end of n! when written in base b. Terminate each scenario with a blank line.

예제 입력 1

3
2 5
10 100
45 10000

예제 출력 1

Scenario #1:
3

Scenario #2:
24

Scenario #3:
2498

출처

University > Tu-Darmstadt Programming Contest > TUD Contest 2006 (Single) 1번