[문제 링크] : https://www.acmicpc.net/problem/14623
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long pow(int n){
int res = 1;
for(int i=0; i<n; i++){
res *= 2;
}
return res;
}
string solve(long long n){
string res = "";
while(n > 0){
res += n % 2 + '0';
n /= 2;
}
reverse(res.begin(), res.end());
return res;
}
int main(){
string A, B;
cin >> A >> B;
long long a = 0, b = 0;
int x = A.length(), y = B.length();
for(int i=0; i<x; i++){
a += A[i] == '1' ? pow(x - (i + 1)) : 0;
}
for(int i=0; i<y; i++){
b += B[i] == '1' ? pow(y - (i + 1)) : 0;
}
string res = solve(a * b);
cout << res << "\n";
return 0;
}
'알고리즘' 카테고리의 다른 글
[알고리즘] 백준 9713 - Sum of Odd Sequence (C++) (0) | 2025.04.27 |
---|---|
[알고리즘] 백준 2596 - 비밀편지 (C++) (0) | 2025.04.26 |
[알고리즘] 백준 10834 - 벨트 (C++) (0) | 2025.04.24 |
[알고리즘] 백준 25704 - 출석 이벤트 (C++) (0) | 2025.04.23 |
[알고리즘] 백준 8723 - Patyki (C++) (0) | 2025.04.22 |