Submission
Status:
PPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: theem1502
Problemset: บวกเลขฐาน
Language: cpp
Time: 0.003 second
Submitted On: 2025-08-20 16:27:02
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
int base;
string num1;
string num2;
cin >> base >> num1 >> num2;
int currentnum = 0;
char *end;
int convertnum1 = strtol(num1.c_str(), &end, base);
int convertnum2 = strtol(num2.c_str(), &end, base);
int thesum = convertnum1 + convertnum2;
if (thesum == 0) {
printf("%d", 0);
return 0;
}
string converted;
string letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
while (thesum > 0) {
converted = letters[thesum % base] + converted;
thesum /= base;
}
cout << converted;
}