-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14623.cpp
52 lines (44 loc) · 814 Bytes
/
14623.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 14623. 감정이입
// 2022.02.01
// 구현
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long pow(int p)
{
int result = 1;
for (int i = 0; i < p; i++)
{
result *= 2;
}
return result;
}
string DecToBin(long long num)
{
string ans = "";
while (num)
{
ans += num % 2 + '0';
num /= 2;
}
reverse(ans.begin(), ans.end());
return ans;
}
int main()
{
string b1, b2;
cin >> b1 >> b2;
long long x = 0;
long long y = 0;
for (int i = 0; i < b1.size(); i++)
{
x += b1[i] == '1' ? pow(b1.size() - (i + 1)) : 0;
}
for (int i = 0; i < b2.size(); i++)
{
y += b2[i] == '1' ? pow(b2.size() - (i + 1)) : 0;
}
cout << DecToBin(x * y) << endl;
return 0;
}