Problem5146--Trailing Zeroes

5146: Trailing Zeroes

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Find the number of trailing zeroes for the following function:
$nC_{r}\ast p^{q}$
wheren, r, p, q are given.
For example, if $n = 10, r = 4, p = 1, q = 1$, then the number is 210 so, number of trailing zeroes is 1.

Input

Input starts with an integer T ($T ≤ 10000$), denoting the number of test cases.
Each case contains four integers: n, r, p, q ($1 ≤ n, r, p, q ≤10^{6}, r ≤ n$).

Output

For each test case, print the case number and the number of trailing zeroes.

Sample 1 Input

2
10 4 1 1
100 5 40 5

Sample 1 Output

Case 1: 1
Case 2: 6

HINT

【题目来源】
http://lightoj.com/volume_showproblem.php?problem=1090。注意这个需要登录。

Source/Category

基础算法 4.2.前缀和