AcWing 3554. 二进制
原题链接
简单
作者:
上层建筑
,
2021-05-25 09:42:41
,
所有人可见
,
阅读 187
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
string func(string s,int high,int sign) {
for(int i=high;i>=0;i--) {
if(sign == 0) break;
else {
if(s[i]=='1') {
s[i] = '0';
if(i==0) s='1'+s;
}
else {
s[i] = '1';
sign--;
}
}
}
return s;
}
int main()
{
int t;
cin >> t;
while(t--) {
string s;
cin >> s;
string temp1 = func(s,31,1);
cout << temp1 << endl;
string temp2 = func(temp1,temp1.size()-2,1);
cout << temp2 << endl;
}
return 0;
}