-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2935.cpp
73 lines (68 loc) · 1.05 KB
/
2935.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 2935. 소음
// 2019.05.21
// 구현
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
string a;
char op;
string b;
cin >> a >> op >> b;
int as = a.size();
int bs = b.size();
vector<char> ans;
if (op == '+') // +일때
{
if (as > bs)
{
ans.push_back('1');
for (int i = 0; i < as - bs - 1; i++)
{
ans.push_back('0');
}
ans.push_back('1');
for (int i = 0; i < bs - 1; i++)
{
ans.push_back('0');
}
}
else if (as < bs)
{
ans.push_back('1');
for (int i = 0; i < bs - as - 1; i++)
{
ans.push_back('0');
}
ans.push_back('1');
for (int i = 0; i < as - 1; i++)
{
ans.push_back('0');
}
}
else // 두 수의 자릿수가 같다면
{
ans.push_back('2');
for (int i = 0; i < as - 1; i++)
{
ans.push_back('0');
}
}
}
else if (op == '*') // *일때
{
ans.push_back('1');
for (int i = 0; i < as + bs - 2; i++)
{
ans.push_back('0');
}
}
for (int i = 0; i < ans.size(); i++)
{
cout << ans[i];
}
cout << endl;
return 0;
}