반응형
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 | #include <iostream> #include <string> using namespace std; int main() { string a, b, c, d; long long ans=0,xs,ys; cin >> a >> b >> c >> d; string x = a + b; string y = c + d; xs = x.size(); ys = y.size(); for (int i = 0; i < xs; i++) { long long cnt = 1; for (int j = 1; j < xs - i; j++) cnt *= 10; ans += (x[i] - '0')*cnt; } for (int i = 0; i < ys; i++) { long long cnt = 1; for (int j = 1; j < ys - i; j++) cnt *= 10; ans += (y[i] - '0')*cnt; } cout << ans <<'\n'; } | cs |
'Algorithm' 카테고리의 다른 글
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10699번:오늘 날짜 답 (0) | 2017.03.06 |
---|---|
(C++) - 백준(BOJ) 3040번 : 백설 공주와 일곱 난쟁이 (0) | 2017.03.06 |
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10707번:수도요금 답 (0) | 2017.03.04 |
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 5988번:홀수일까 짝수일까 답 (0) | 2017.03.01 |
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 12790번:Mini Fantasy War 답 (0) | 2017.02.27 |