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
#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a, b, w;
    short A, B, i, r, c;
    i = r = 0;
    cin >> a >> b;
    A = a.size();
    B = b.size();
    while (i < A && i < B){
        c = a[A - i - 1] - '0' + b[B - i - 1] - '0' + r;
        r = c/10;
        w += char(char(c - 10*r) + '0');
        i++;
    }
    if (i < A){
        while (i < A){
            c = a[A - i - 1] - '0' + r;
            r = c/10;
            w += char(char(c - 10*r) + '0');
            i++;
        }
    }
    else if (i < B){
        while (i < B){
            c = b[B - i - 1] - '0' + r;
            r = c/10;
            w += char(char(c - 10*r) + '0');
            i++;
        }
    }
    if (r != 0){
        w += char(char(r) + '0');
    }
    A = w.size();
    for (int i = 0; i < A; i++){
        cout << w[A - i - 1];
    }
    return 0;
}