Submission

Status:

Compilation Error

Subtask/Task Score:

Score: 0

User: shurye

Problemset: บวกเลขฐาน

Language: cpp

Time: 0.000 second

Submitted On: 2026-10-14 20:22:04

#include <string>
#include <iostream>
using namespace std ;
int main() {
    int base ,DeciNum1 = 0,DeciNum2 = 0;
    string num1 , num2 ;
    cin >> base >> num1 >> num2 ;
    for(int i = 0 ; i <num1.length() ; i++){
        if(isnumber(num1[i])){
            DeciNum1 += (num1[i]-'0')*(pow(base,num1.length()-1-i));
        }else{
            DeciNum1 += (num1[i]-55)*(pow(base,num1.length()-1-i));
        }
    }
    for(int i = 0 ; i <num2.length() ; i++){
        if(isnumber(num2[i])){
            DeciNum2 += (num2[i]-'0')*(pow(base,num2.length()-1-i));
        }else{
            DeciNum2 += (num2[i]-55)*(pow(base,num2.length()-1-i));
        }
    }int N = DeciNum2 + DeciNum1 ;
    string NumOut = "" ;
    while(N != 0){
        if(N%base <10){
            NumOut = char(N%base+'0') + NumOut ;
        }else{
            NumOut = char(N%base+55) + NumOut ;
        }N = N/base;
    }cout << NumOut ;
}