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
#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string A,B,C;
    cin>>A>>B;
    if(A.size()<B.size()){swap(A,B);}
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    A.push_back('0');
    while(B.size()<A.size())
    {
        B.push_back('0');
    }
    for(int i=0;i<A.size();i++)
    {
        C.push_back(A[i]+B[i]-(int)'0');
        if(C[i]>'9'){A[i+1]++;C[i]-=10;}
    }
    while(C.size()>0&&C.back()=='0')
    {
        C.pop_back();
    }
    reverse(C.begin(),C.end());
    if(C.size()==0){C="0";}
    cout<<C<<endl;
    return 0;
}