This page is still under construction.

Parts of this page are still being built. What you see may change.

One Person “The Price is Right”

Time limit1sMemory limit128 MB

Summary
Given G guesses and L lifelines, find the largest N such that a strategy guarantees a win for any price from 1 to N.
Level

Medium6 of 10

Topics
Dynamic programming, Game theory
Solved
No attempts yet

Problem

In the game show “The Price is Right”, a number of players (typically 4) compete to get on stage by guessing the price of an item. The winner is the person whose guess is the closest one not exceeding the actual price. Because of the popularity of the one-person game show “Who Wants to be a Millionaire”, the American Contest Management (ACM) would like to introduce a one-person version of “The Price is Right”.

In this version, each contestant is allowed GG (1≤G≤301 \le G \le 30) guesses and LL (0≤L≤300 \le L \le 30) lifelines. The contestant makes a number of guesses for the actual price. After each guess, the contestant is told whether it is correct, too low, or too high. If the guess is correct, the contestant wins. Otherwise, the guess is used up. Additionally, if the guess is too high, a lifeline is also lost. The contestant loses when all guesses are used up, or if a guess is too high and no lifelines remain. All prices are positive integers.

It turns out that for a particular pair of values GG and LL, there is a guessing strategy such that if the price is between 11 and NN (inclusive) for some NN, the player can guarantee a win. The organizers do not want every contestant to win, so the actual price must exceed NN; at the same time the game should not be so hard that too few contestants win. Given GG and LL, what is the largest value of NN such that a strategy exists to win whenever the price is between 11 and NN (inclusive)?

Input

The input consists of several cases. Each case is a single line containing two integers GG and LL separated by one space. The end of input is a line with G=L=0G = L = 0, which must not be processed.

Output

For each case, print one line of the form:

Case c: N

where cc is the case number (starting from 11) and NN is the computed value.

Examples1

  1. Example 1

    Input
    3 0
    3 1
    10 5
    7 7
    0 0
    
    Expected output
    Case 1: 3
    Case 2: 6
    Case 3: 847
    Case 4: 127