알고리즘/BOJ
[C++] 백준 12813번 - 이진수연산
Jay, Lee
2022. 5. 22. 23:32
어렵지는 않지만 채점하는데 시간이 너무 오래 걸렸던 문제
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
char a[100001];
char b[100001];
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> a >> b;
for (int i = 0; i < strlen(a); i++) {
if (a[i] == '1' && b[i] == '1') cout << '1';
else cout << '0';
}
cout << endl;
for (int i = 0; i < strlen(a); i++) {
if (a[i] == '1' || b[i] == '1') cout << '1';
else cout << '0';
}
cout << endl;
for (int i = 0; i < strlen(a); i++) {
if (a[i] != b[i]) cout << '1';
else cout << '0';
}
cout << endl;
for (int i = 0; i < strlen(a); i++) {
if (a[i] == '1') cout << '0';
else cout << '1';
}
cout << endl;
for (int i = 0; i < strlen(a); i++) {
if (b[i] == '1') cout << '0';
else cout << '1';
}
cout << endl;
return 0;
}