Submission
Status:
PPPPPPP-P
Subtask/Task Score:
96/100
Score: 96
User: chs_14
Problemset: บวกเลขฐาน
Language: cpp
Time: 0.002 second
Submitted On: 2025-11-19 21:28:59
#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 = "";
while (result>0)
{
result_str+=symbols[result%base];
result/=base;
}
reverse(result_str.begin(), result_str.end());
cout << result_str << '\n';
return 0;
}