Submission
Status:
-------P-
Subtask/Task Score:
12/100
Score: 12
User: chs_14
Problemset: บวกเลขฐาน
Language: cpp
Time: 0.003 second
Submitted On: 2025-11-22 09:36:37
#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;
}
if (result==0) {
result_str+='0';
}
reverse(result_str.begin(), result_str.end());
cout << result_str << '\n';
return 0;
}