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
#include<bits/stdc++.h>
using namespace std;

const int x = 100007;
int A[x], B[x], W[x];

int main(){
    string a1, b1;
    cin >> a1 >> b1;
    reverse(a1.begin(), a1.end());
    reverse(b1.begin(), b1.end());
    int n = max(a1.size(), b1.size());

    for (int i = 0; i < a1.size(); i++){
        A[i] = a1[i]-'0';
    }
    for (int i = 0; i < b1.size(); i++){
        B[i] = b1[i]-'0';
    }
    int carry = 0;
    int j=0;
    for (int i = 0; i < n; i++){
        W[i] = (A[i] + B[i] + carry)%10;
        carry = (A[i] + B[i]+ carry)/10;
        j++;
    }
    if (carry != 0){
        W[n] += carry;
        j++;
    }




/*
    for (int i = 0; i < n+1; i++) cout << A[i] << " ";
    cout << "\n";
    for (int i = 0; i < n+1; i++) cout << B[i] << " ";
    cout << "\n";
    for (int i = 0; i < n+1; i++) cout << W[i] << " ";
*/
    string wynik = "";
    for (int i = j-1; i >= 0; i--){
        cout << W[i];
    }
    //cout << endl <<  j;
    return 0;
}