#Lutece0728. Everyone out of the Pool
Everyone out of the Pool
Migrated from Lutece 728 Everyone out of the Pool
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
When you rent a table at a pool hall, the proprietor gives you a -by- tray of balls, as shown in Figure (a) below. One of these balls, called the "cue ball", is white, and the remaining are numbered through . At the beginning of a game,the numbered balls are racked up in a triangle (without the cue ball), as shown in Figure (b).
Now imagine other pool-like games where you have a cue ball and x numbered balls. You'd like to be able to rack up the numbered balls in a triangle, and have all balls perfectly fill a square -by- tray. For what values of is this possible? In this problem you'll be given an lower bound and upper bound , and asked how many numbers within this range have the above property.
Input
Input for each test case will one line containin two integers , where . The line 0 0
will follow the last test case.
Output
For each test case one line of output as follows:
Case n: k
if there are integers such that , balls can be racked up in a triangle, and balls fill a square tray.
Samples
15 17
14 16
1 20
0 0
Case 1: 1
Case 2: 0
Case 3: 2
Resources
2011 East Central Regional Contest