A.Phoenix and Balance
CF1348 A
question meaning: given nnn operations,iii time you can go toa / ba/ba / b Kagami2 i 2 ^ i2i , requiresa, ba, bboth a and b are addedn 2 \frac{n}{2}2nTimes. Find ∣ a − b ∣ |ab|∣a−b The minimum value of ∣ .
Idea:
A water problem in binary It
can be known thatfor 2i, it is greater than∑ k = 1 i − 1 2 i \sum_{k=1}^{i-1} 2^i∑k=1i−12i
so supposebbb is a larger number, just put2 n 2^n2n forbbb , add the rest tobbfrom the smallestb on. Give the rest toaaa。
int main(){
int t=ird();
LL n,a,b;
while(t--){
n=lrd();
b=qpow(2,n+1)-2;
a=qpow(2,n);
for(int i=1;i<n/2;i++){
a+=qpow(2,i);
}
b-=a;
a-=b;
cout<<a<<endl;
}
}