Problem 1: The Winning Percentage

advertisement
November 5, 2005
ACM North Central North America Regional Programming Contest
Problem 1
Problem 1: The Winning Percentage
The display of the percentage of games won for various computer-based games is frequently
reported as an integer, with any fractional part truncated. For example, if you had won 7 out of 11
games, the winning percentage would be reported as 63 percent, even though the actual percentage
is closer to 64 percent (63.6363… percent).
Suppose you are told the winning percentage (as described above, with the fractional part
truncated). You are to find the N smallest numbers of games played and the corresponding number
of those that you won that will yield the reported winning percentage.
For example, with a winning percentage of 63 percent, the first 3 pairs (Won, Played) would be (7,
11), (12, 19), and (14, 22).
Input
The input will contain multiple cases. The input for each case will consist of two integers. The first
of these, P, is the percentage of games won – as displayed by the game. This will obviously be no
larger than 100. The second integer, N, is the number of pairs (Won, Played) you are to determine.
Input for the last case will be followed by a pair of zeroes.
Output
For each case, display the case number (they start with 1 and increase sequentially) and the values
of P and N from the input. Then, on separate additional lines, display the pairs (Won, Played) that
will yield the specified integer percentage. The first such pair will have the smallest value of
Played that is possible, and the entire set of pairs will be displayed in ascending order on the
number of games played. Your output should resemble that shown in the sample below.
Sample Input
0 5
50 4
75 5
0 0
November 5, 2005
Output for the Sample Input
Case 1: p = 0, n = 5
0 games out of 1
0 games out of 2
0 games out of 3
0 games out of 4
0 games out of 5
Case 2: p = 50, n = 4
1 games out of 2
2 games out of 4
3 games out of 6
4 games out of 8
Case 3: p = 75, n = 5
3 games out of 4
6 games out of 8
9 games out of 12
12 games out of 16
15 games out of 20
ACM North Central North America Regional Programming Contest
Problem 1
Download