-->
当前位置:首页 > 题库

PROGRAMMING:Special Christmas tree

Luz5年前 (2021-05-10)题库432
Christmas is coming. Everyone is building a Christmas tree, and you are no exception. However, you are special and you want to build a special tree. You decide to build a binary Christmas tree and hang its roots from the ceiling. For a binary tree, the top node is called the root node. Each node in the tree may have 0, 1 or 2 child nodes, and the node without child nodes is called the leaf. Except that the root node has no parent node, each node has and only has one parent node. You buy a decoration bag, which contains some decorations. You want to use them to decorate all the leaves on the tree. Because of the height limit of your room, the tree can't be higher than your house. The height of a tree is the number of sides along the path from the root to the farthest leaf. Please note that each leaf must be decorated with an ornament (each ornament can decorate one leaf). You must use all the ornaments to decorate your Christmas tree. You need to design a special Christmas tree, that is, a binary tree with limited height and leaf number and as many nodes as possible. Can you find the most special tree?
###Input format:
Your program will be tested on one or more test cases. The first line of input is a single integer t (1 ≤ t ≤ 10000), indicating the number of test cases. Next is the T-group test case. Each test case will include two integers h and l (0 ≤ h ≤ 1000000000, 1 ≤ L ≤ 1000000000 and 1 ≤ L ≤ 2 ^ H) separated by spaces, representing the maximum possible height and the number of leaves, respectively.
###Output format:
For each test case, print a single line containing case n: ans (where n is the number of the test case and ANS is the node number of the most special Christmas tree). See the example for details.
###Input example:
Here is a set of inputs. For example:
```in
two
3 2
3 3
```
###Output example:
The corresponding output is given here. For example:
```out
Case 1: 7
Case 2: 9
```







answer:If there is no answer, please comment