Advertisement
jakaria_hossain

codeforces - phoenix and balance

May 1st, 2020
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
  5. int main()
  6. {
  7.     fast();
  8.     ll t ;
  9.     cin>>t;
  10.     while(t--)
  11.     {
  12.         ll n;
  13.         cin>>n;
  14.         ll sum=0, sum2=0;
  15.         ll ara[n+2];
  16.         for(ll i=1 ; i<=n;i++)
  17.         {
  18.             ara[i]=pow(2,i);
  19.             sum+=ara[i];
  20.             if(i<n/2 || i==n)sum2+=ara[i];
  21.         }
  22.         sum= sum-sum2;
  23.         cout<<abs(sum-sum2)<<endl;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement