Submission
Status:
PPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: samsenpisardmoo26
Problemset: บวกเลขฐาน
Language: cpp
Time: 0.003 second
Submitted On: 2026-10-07 02:49:17
#include <bits/stdc++.h>
using namespace std;
string convert(int n, int b)
{
string digits = "0123456789ABCDEF";
if(n==0) return "0";
string ans = "";
while(n!=0)
{
int mod = n%b;
ans = digits[mod] + ans;
n/=b;
}
return ans;
}
int main()
{
cin.tie(NULL) -> sync_with_stdio(false);
int b;
cin >> b;
string num1, num2;
cin >> num1 >> num2;
long long ans1 = stoll(num1, nullptr, b);
long long ans2 = stoll(num2, nullptr, b);
ans1+=ans2;
cout << convert(ans1, b);
}