题目描述
C++ 代码
string s;
string change(int n){
int sum = 32;
string res = "";
for(; n; n>>=1){
res += to_string(n&1);
sum--;
}
if(sum > 0) while(sum--) res += '0';
reverse(res.begin(), res.end());
return res;
}
void solve(){
cin >> s;
bitset<32> n(s);
int val = n.to_ullong();
cout << change(val+1) << endl;
cout << change(val+3) << endl;
}
注:代码中的int实质为long long