文章
121
粉丝
68
获赞
94
访问
20.3k
#include <bits/stdc++.h>
using namespace std;
string intToBinary(int x){
string s;
while(x!=0){
s.push_back(x%2+'0');
x/=2;
}
while(s.size()<32)s.push_back('0');
return s;
}
long long binaryReverseTransInt(string s){
long long ans=0;
for(int i=0;i<s.size();i++){
int k=s[i]=='0'?0:1;
ans*=2;
ans+=k;
}
return ans;
}
int main(){
int n;
while(cin>>n){
while(n--){
long long x;cin>>x;
cout<<binaryReverseTransInt(intToBinary(x))<<endl;
}
}
}
登录后发布评论
暂无评论,来抢沙发