Submission

Status:

PPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chs_14

Problemset: บวกเลขฐาน

Language: cpp

Time: 0.003 second

Submitted On: 2025-11-22 09:37:38

#include <bits/stdc++.h>
using namespace std;

int main() {
    string num1, num2;
    int base, n1, n2;
    string symbols = "0123456789ABCDEF";

    cin >> base >> num1 >> num2;
    n1 = stoi(num1, nullptr, base);
    n2 = stoi(num2, nullptr, base);
    int result = n1+n2;
    string result_str = "";

    if (result==0) {
        result_str+='0';
    }
    while (result>0)
    {
        result_str+=symbols[result%base];
        result/=base;
    }


    reverse(result_str.begin(), result_str.end());
    cout << result_str << '\n';

    return 0;
}