2591 cin >> str_n >> str_a >> str_b;
2596 for(
int i = str_n.length() - 1; i >= 0; i--) {
2597 if(str_n[i] ==
'0') {
2600 n.push_back(str_n[i] -
'0');
2603 for(
int i = str_a.length() - 1; i >= 0; i--) {
2604 a.push_back(str_a[i] -
'0');
2606 for(
int i = str_b.length() - 1; i >= 0; i--) {
2607 b.push_back(str_b[i] -
'0');
2610 for(
int i = 0; i < max(a.size(), b.size()) || carry != 0; i++) {
2611 const int radix = i < n.size() ? n[i] : 10;
2612 const int num_a = i < a.size() ? a[i] : 0;
2613 const int num_b = i < b.size() ? b[i] : 0;
2614 const int sum = num_a + num_b + carry;
2615 ans.push_back(sum % radix);
2616 carry = sum / radix;
2618 int i = ans.size() - 1;
2619 while(ans[i] == 0 && i > 0) {
2622 for(; i >= 0; i--) {