AcWing 3554. 二进制
原题链接
简单
作者:
王小强
,
2021-06-02 18:56:06
,
所有人可见
,
阅读 323
活动打卡
#include <iostream>
using namespace std;
string helper(long int x) {
if (x == 0) return "";
return helper(x / 2) + to_string(x % 2);
}
string conv(long int x) {
if (x == 0) return "0";
string s = helper(x);
while (s.length() < 32)
s = "0" + s;
return s;
}
int main(int argc, const char** argv) {
int n;
long x;
string s;
cin >> n;
while (n--) {
cin >> s;
x = stol(s, nullptr, 2);
cout << conv(x + 1) << endl;
cout << conv(x + 3) << endl;
}
return 0;
}