提交时间:2024-08-20 16:21:40

运行 ID: 169322

#include <bits/stdc++.h> using namespace std; int a[110], b[110], jw[110]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } string ans = ""; for (int i = n; i >= 1; i--) { ans += char((a[i] + b[i] + jw[i]) % 10 + '0'); jw[i - 1] = (a[i] + b[i] + jw[i]) / 10; } if (jw[0] > 0) ans += char(jw[0] % 10 + '0'); reverse(ans.begin(), ans.end()); cout << ans << endl; return 0; }