CF1348A.Phoenix and Balance
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Phoenix has n coins with weights 21,22,…,2n . He knows that n is even.
He wants to split the coins into two piles such that each pile has exactly 2n 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≤t≤100 ) — the number of test cases.
The first line of each test case contains an integer n ( 2≤n≤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 .