P21313 [CodeChef] EXPENSES
普及-
题目描述

Chef has made a list for his monthly expenses. The list has N expenses with index 1 to N. The money spent on each expense depends upon the monthly income of Chef.

Chef spends 50\% of his total income on the expense with index 1.
The money spent on the i^{th} expense (i>1) is equal to 50\% of the amount remaining, after paying for all expenses with indices less than i.

Given that Chef earns 2^{X} rupees in a month, find the amount he saves after paying for all N expenses.

------ Input Format ------

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers N and X — where N denotes the number of expenses and 2^{X} denotes the monthly income of Chef.

------ Output Format ------

For each test case, output on a new line, the amount saved by Chef after paying for all N expenses.

------ Constraints ------

$1 ≤ T ≤ 1000$
$1 ≤ N< X ≤ 20$

----- Sample Input 1 ------
4
1 2
1 3
2 3
3 4

----- Sample Output 1 ------
2
4
2
2
----- explanation 1 ------
Test case $1$: The number of expenses are $1$ and Chef's monthly income is $2^{2} = 4$.
Chef spends $50\%$ of his monthly income, that is, $2$ on first expense and saves the remaining amount $4-2 = 2$.

Test case $2$: The number of expenses are $1$ and Chef's monthly income is $2^{3} = 8$.
Chef spends $50\%$ of his monthly income, that is, $4$ on first expense and saves the remaining amount $8-4 = 4$.

Test case $3$: The number of expenses are $2$ and Chef's monthly income is $2^{3} = 8$.
- Chef spends $50\%$ of his monthly income, that is, $4$ on first expense. The remaining amount is $8-4=4$.
- Chef spends $50\%$ of the remaining amount, that is, $2$ on his second expense. The remaining amount is $4-2=2$ which goes into his savings.

Test case $4$: The number of expenses are $3$ and Chef's monthly income is $2^{4} = 16$.
- Chef spends $50\%$ of his monthly income, that is, $8$ on first expense. The remaining amount is $16-8=8$.
- Chef spends $50\%$ of the remaining amount, that is, $4$ on second expense. The remaining amount is $8-4=4$.
- Chef spends $50\%$ of the remaining amount, that is, $2$ on his third expense. The remaining amount is $4-2=2$ which goes into his savings.

输入格式

见题面

输出格式

见题面

样例输入
4 1 2 1 3 2 3 3 4
样例输出
2 4 2 2