G |
Next
to Never Input: Standard Input Output: Standard Output |
|
Geometric series have many important roles in mathematics. An infinite geometric series that has a positive integer as first term and whose general ratio is a non-negative rational number can be written as follows:
Here a is the first term of geometric series and p and q are non negative integer numbers.
Infinite geometric series
converges when the general ratio is less than 1 and diverges when the general
ratio is greater than or equal to 1. In other words converging infinite
geometric series has summation less than infinity. But for this problem, a
converging geometric series is a series whose sum does not exceed a given
value, as "less than infinity" does not indicate any specific value.
We refer this given value as NEXT_TO_NEVER in this problem. So given the value
of NEXT_TO_NEVER and a, your job is to find out how many different
fractions
Input
Input file contains less than 550 sets of inputs. The description for each set is given below:
The input for each set is given in a single line. This line contains three integers NEXT_TO_NEVER (1000≤NEXT_TO_NEVER≤10000), a (1≤a≤5) and MAXV (20000≤MAXV≤100000). Meaning of NEXT_TO_NEVER and a is already given in the problem statement. The value MAXV indicates the maximum possible value of p and q. Note that the minimum possible value for p and q is 0 (zero) and 1 (One) respectively.
Input is terminated by a line containing three zeroes.
Output
For each line
of input produce one line of output. This line contains the serial of output
followed by two integers s and t. The first integer s denotes how many
different possible fractions
1000 1 20000 0 0 0 |
Case
1: 121468930 199820000 |