forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
25 lines (19 loc) · 539 Bytes
/
2.cpp
File metadata and controls
25 lines (19 loc) · 539 Bytes
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
#include <bits/stdc++.h>
using namespace std;
string str;
int main(void) {
cin >> str;
// 첫 번째 문자를 숫자로 변경한 값을 대입
long long result = str[0] - '0';
for (int i = 1; i < str.size(); i++) {
// 두 수 중에서 하나라도 '0' 혹은 '1'인 경우, 곱하기보다는 더하기 수행
int num = str[i] - '0';
if (num <= 1 || result <= 1) {
result += num;
}
else {
result *= num;
}
}
cout << result << '\n';
}