Pro.ID22234 TitleTournament Seeding Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22234 AC0 Submit0 Ratio- 时间&空间限制描述In many competitions, players are given seeding numbers to represent their relative strength, where the best player is given seed #1, the second best is given seed #2, etc. The seeding of a single elimination tournament is an arrangement of matches which keeps the best players from playing each other until as late as possible (the last round with players seeded 1 and 2). Define the strength for a match as the sum of the two seeds in the match, and the ideal strength as the strength for the match assuming the best two players make it to that match (or in other words, the minimum sum of the two seeds which could play in that match). The total number of rounds r needed for a tournament of n contestants is given by the formula . If we call the finals of the tournament round r, the semi-finals round r-1, etc., then the way in which seeding is done can be described as follows: in round k, we arrange players such that the ideal match strength for all matches in that round is 2r-k+1+1. For example, the seeding of a match of 13 people would look as follow: You are asked to solve the following problem: given the values of n and m, determine the earliest round in a tournament of n players in which a match strength of m could occur. You may assume that the seeding is done in the manner described above. 输入You will be given a number of cases in the input. Each case will be specified on one line, consisting of two integers n and m, where 2 ≤ n ≤ 100 and m ≥ 3. You may assume in each case that a match strength of m can occur during some round. Input is terminated by a case in which n = m = 0. 输出Description In many competitions, players are given seeding numbers to represent their relative strength, where the best player is given seed #1, the second best is given seed #2, etc. The seeding of a single elimination tournament is an arrangement of matches which keeps the best players from playing each other until as late as possible (the last round with players seeded 1 and 2). Define the strength for a match as the sum of the two seeds in the match, and the ideal strength as the strength for the match assuming the best two players make it to that match (or in other words, the minimum sum of the two seeds which could play in that match). The total number of rounds r needed for a tournament of n contestants is given by the formula . If we call the finals of the tournament round r, the semi-finals round r-1, etc., then the way in which seeding is done can be described as follows: in round k, we arrange players such that the ideal match strength for all matches in that round is 2r-k+1+1. For example, the seeding of a match of 13 people would look as follow: You are asked to solve the following problem: given the values of n and m, determine the earliest round in a tournament of n players in which a match strength of m could occur. You may assume that the seeding is done in the manner described above. Input You will be given a number of cases in the input. Each case will be specified on one line, consisting of two integers n and m, where 2 ≤ n ≤ 100 and m ≥ 3. You may assume in each case that a match strength of m can occur during some round. Input is terminated by a case in which n = m = 0. Output For each test case, print the case number and the earliest round for that case in the format shown below. Sample Input 100 3 Sample Output Case 1: Round 7 Source 样例输入100 3 样例输出Case 1: Round 7 作者 |