Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
908 B
0
Indexable
Never
#define ll long long
#define pb push_back
#include <bits/stdc++.h>
using namespace std;

vector<ll> bin(ll n){
    vector<ll>res;
    while(n>0){
        res.pb(n%2);
        n/=2;
    }
    reverse(res.begin(),res.end());
    return res;
}

ll dec(vector<ll>& vec) {
    ll decimalNumber = 0;
    ll base = 1;
    for (int i =vec.size()-1;i>=0;i--) {
        decimalNumber+=vec[i]*base;
        base *= 2;
    }
    return decimalNumber;
}


void solve(){
    ll x;
    cin>>x;
    
    vector<ll>binx=bin(x);
    ll n=binx.size();
    vector<ll> a,b;
    ll ans=1;
    ll count=0;
    bool first=false;
    for(int i=1;i<n;i++){
        if(binx[i]==1) {first=true; continue;}
        
        if(binx[i]==0 && first){
            ans*=2;
        }
    }
    
    cout<<ans<<"\n";
}



signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
	cin>>t;
	while(t--) solve();
}
Leave a Comment