Problem 9: Number of Numbers

Sets of integers having particular properties appear in lots of applications. In this problem, you are to determine the number of integers in a particular set. Each set to be considered has the value first as its smallest value, and the value last as its largest value. first and last are supplied as input data items. Every other integer in the set is larger than first and smaller than last, and also has the property that it differs from another element already in the set by diff (another integer value that will be supplied in the input).

Lets consider an example. Suppose first = 1, last = 10, and diff = 3. Clearly 1 and 10 are in the set. first + diff = 4 is also in the set. last  diff = 7 is in the set as well. Now we can consider 4 + diff = 7 for membership. But 7 is already in the set. Clearly this set includes only the integers 1, 4, 7, and 10. The number of elements in the set is 4, and that would be the proper output for this input.

Input

The input will contain multiple cases. The input for each case contains three integers, specifically first, last, and diff. The input for the last case will be followed by input for which first > last; this case is not to be considered as the specification of another set.

Output

For each input case, display the case number (they are numbered sequentially starting with one), and the number of integers in the set. Leave a blank line between the output for each case. The examples shown below illustrate an acceptable output format.

Sample Input

1 10 3

10 100 10

11 30 19

27 36 4

2 1 0

 

Expected Output

Case 1: Set contains 4 integers.

 

Case 2: Set contains 10 integers.

 

Case 3: Set contains 2 integers.

 

Case 4: Set contains 6 integers.