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
#include <iostream>

using namespace std;

const int MAX = 5001;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a, b, c;
    int k=0,j;
    cin >> a >> b;
    if(a.size() < b.size()) c = a, a = b, b = c;
    c = "";
    char s;
    j=b.size()-1;
    for(int i=a.size()-1; i>=0; i--)
    {
        if(j < 0) s = '0';
        else s = b[j];
        int x = a[i] - '0', y = s - '0';
        char d = '0' + (x+y+k)%10;
        c = d + c;
        if(x+y+k>=10) k = 1;
        else k = 0;
        j--;
    }
    cout << c;
}