You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
609 B

#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N], al;
int b[N], bl;
void add(int a[], int &al, int b[], int &bl) {
int t = 0;
al = max(al, bl);
for (int i = 1; i <= al; i++) {
t += a[i] + b[i];
a[i] = t % 10;
t /= 10;
}
if (t) a[++al] = 1;
}
int main() {
string x, y;
cin >> x >> y;
for (int i = x.size() - 1; i >= 0; i--) a[++al] = x[i] - '0';
for (int i = y.size() - 1; i >= 0; i--) b[++bl] = y[i] - '0';
add(a, al, b, bl);
for (int i = al; i; i--) printf("%d", a[i]);
return 0;
}