forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
49 lines (47 loc) · 900 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**************************************************************************
* $Id$
* File:
*
* Purpose:
*
* Author: Sanchit Gupta (CS19B071)
*
* Created:
*
* Last modified:
*
* Bugs:
*
* Change Log:
*
* While(!(succeed==try());
**************************************************************************/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n;
cin>>n;
long long int sum1=0,sum2=0;
long long int current=2,i=1;
while(i<(n/2))
{
sum1=sum1+current;
current=current*2;
i++;
}
while(i<n)
{
sum2=sum2+current;
current=current*2;
i++;
}
sum1=sum1+current;
cout<<abs(sum1-sum2)<<endl;
}
}