#Lutece0568. Battery Charging
Battery Charging
Migrated from Lutece 568 Battery Charging
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
Recently, qbwj bought a powerful cellphone which performs even better than most computers. He spent lots of time on it. However, this cellphone has a very strange feature which confused qbwj. There is a battery with infinite capacity in the cellphone. On each day, qbwj has three choices: use the cellphone, charge the battery or do nothing. He cannot do using and charging on the same day. Charging on the day adds units of power to the battery. If qbwj chooses to use the cellphone on the day, it would consume units of power. Note that qbwj can choose to use the cellphone if and only if there are enough units of power in the battery.
Despite of the strengths of the cellphone, qbwj couldn't suffer it any more. So he decides to sell it at the end of day. Today is the Sth day and the battery is empty now. He wants to know how many days at maximum he can use the cellphone before selling it out.
Note that qbwj can still choose to use the cellphone on both the day and day.
Input
The first line of the input will be an integer () indicating the number of cases.
For each test case, two integers are given on a single line: . .
Output
Print Case #k: d
in a single line for each test case, in which represents the case number which starts from , and is the answer.
Samples
3
3 6
3 9
1 100000
Case #1: 1
Case #2: 3
Case #3: 49994
Note
For the first sample, we charge the cellphone on the , , day and use it on the day.
Resources
10th UESTC Programming Contest Final