// Grzegorz Ryn
// Jagiellonian University
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define st first
#define nd second
#define all(__VAR) (__VAR).begin(), (__VAR).end()
#define DEBUG(__VAR) cout << #__VAR << ": " << __VAR << endl;
template <typename T, typename U>
ostream & operator<<(ostream &out, const pair<T, U> &var) {
cout << "{" << var.st << ", " << var.nd << "}";
return out;
}
template <typename T>
ostream & operator<<(ostream &out, const vector<T> &var) {
cout << "[";
for(int i=0; i<(int)var.size()-1; i++) {
cout << var[i] << ", ";
}
if(var.size()>0)
cout << var.back();
cout << "]" << endl;
return out;
}
const int inf = 1'000'000'000;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string a, b;
cin >> a >> b;
int MAXN = 5000 + 10;
vector<int> res(MAXN, 0);
int N = a.length(), M = b.length();
for(int i=0; i<N; i++) {
res[i] += (int)(a[N-i-1]-'0');
}
for(int i=0; i<M; i++) {
res[i] += (int)(b[M-i-1]-'0');
}
for(int i=0; i<MAXN-1; i++) {
res[i+1] += res[i]/10;
res[i] %= 10;
}
while(res.back() == 0) {
res.pop_back();
}
while(res.size() > 0) {
cout << res.back();
res.pop_back();
}
cout << '\n';
return 0;
}
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | // Grzegorz Ryn // Jagiellonian University #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define st first #define nd second #define all(__VAR) (__VAR).begin(), (__VAR).end() #define DEBUG(__VAR) cout << #__VAR << ": " << __VAR << endl; template <typename T, typename U> ostream & operator<<(ostream &out, const pair<T, U> &var) { cout << "{" << var.st << ", " << var.nd << "}"; return out; } template <typename T> ostream & operator<<(ostream &out, const vector<T> &var) { cout << "["; for(int i=0; i<(int)var.size()-1; i++) { cout << var[i] << ", "; } if(var.size()>0) cout << var.back(); cout << "]" << endl; return out; } const int inf = 1'000'000'000; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string a, b; cin >> a >> b; int MAXN = 5000 + 10; vector<int> res(MAXN, 0); int N = a.length(), M = b.length(); for(int i=0; i<N; i++) { res[i] += (int)(a[N-i-1]-'0'); } for(int i=0; i<M; i++) { res[i] += (int)(b[M-i-1]-'0'); } for(int i=0; i<MAXN-1; i++) { res[i+1] += res[i]/10; res[i] %= 10; } while(res.back() == 0) { res.pop_back(); } while(res.size() > 0) { cout << res.back(); res.pop_back(); } cout << '\n'; return 0; } |
English