307377: CF1348A. Phoenix and Balance

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Phoenix and Balance

题意翻译

## 题目描述 - 有 $n$ 个银币,价值分别为 $2^1,2^2,\dots,2^n$,$n$ 为偶数 - 你要将它们分成两组,每组 $\frac{n}{2}$ 个 - 设第一组所有银币价值之和为 $a$,第二组价值之和为 $b$。求 $|a-b|$ 的最小值。 ## 输入格式 本题多测。 第一行一个整数 $T$,测试组数。 接下来 $T$ 行每行一个整数 $n$,保证 $n$ 为偶数。 ## 输出格式 对于每组数据,输出一个整数表示答案 ## 数据范围与约定 - $1 \leq T \leq 100$ - $2 \leq n \leq 30$

题目描述

Phoenix has $ n $ coins with weights $ 2^1, 2^2, \dots, 2^n $ . He knows that $ n $ is even. He wants to split the coins into two piles such that each pile has exactly $ \frac{n}{2} $ coins and the difference of weights between the two piles is minimized. Formally, let $ a $ denote the sum of weights in the first pile, and $ b $ denote the sum of weights in the second pile. Help Phoenix minimize $ |a-b| $ , the absolute value of $ a-b $ .

输入输出格式

输入格式


The input consists of multiple test cases. The first line contains an integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. The first line of each test case contains an integer $ n $ ( $ 2 \le n \le 30 $ ; $ n $ is even) — the number of coins that Phoenix has.

输出格式


For each test case, output one integer — the minimum possible difference of weights between the two piles.

输入输出样例

输入样例 #1

2
2
4

输出样例 #1

2
6

说明

In the first test case, Phoenix has two coins with weights $ 2 $ and $ 4 $ . No matter how he divides the coins, the difference will be $ 4-2=2 $ . In the second test case, Phoenix has four coins of weight $ 2 $ , $ 4 $ , $ 8 $ , and $ 16 $ . It is optimal for Phoenix to place coins with weights $ 2 $ and $ 16 $ in one pile, and coins with weights $ 4 $ and $ 8 $ in another pile. The difference is $ (2+16)-(4+8)=6 $ .

Input

题意翻译

## 题目描述 - 有 $n$ 个银币,价值分别为 $2^1,2^2,\dots,2^n$,$n$ 为偶数 - 你要将它们分成两组,每组 $\frac{n}{2}$ 个 - 设第一组所有银币价值之和为 $a$,第二组价值之和为 $b$。求 $|a-b|$ 的最小值。 ## 输入格式 本题多测。 第一行一个整数 $T$,测试组数。 接下来 $T$ 行每行一个整数 $n$,保证 $n$ 为偶数。 ## 输出格式 对于每组数据,输出一个整数表示答案 ## 数据范围与约定 - $1 \leq T \leq 100$ - $2 \leq n \leq 30$

加入题单

算法标签: