Submission

Status:

PPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Phat12

Problemset: บวกเลขฐาน

Language: cpp

Time: 0.003 second

Submitted On: 2025-08-24 15:38:58

#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define rizz ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
const int MOD = 1e9+7;
const int diri[] = {0,0,-1,1};
const int dirj[] = {1,-1,0,0};
using namespace std;
template<class T>
using minheap = priority_queue<T,vector<T>,greater<T>>;
using pii = pair<int,int>;
const char bruh[] = {"0123456789ABCDEF"};
int32_t main(){
    rizz;
    int base;
    string a,b;
    string c;
    cin >> base >> a >> b;
    int sum = stoll(a,0,base)+stoll(b,0,base);
    //cerr << stoi(a,0,base) << ' ' << stoi(b,0,base) << ' ' << sum;
    while (sum){
        c+=bruh[(sum)%base];
        sum/=base;
    }
    reverse(all(c));
    cout << ((c.empty()) ? "0" : c);
    return 0;
}