Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Bestzu

Problemset: แปลงเลขฐาน

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-02 23:32:27

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

string change_base(int a, int base) {
    if(a == 0) return "0";

    string s;
    while(a > 0) {
        s.push_back('0' + a%base);
        a /= base;
    }
    reverse(s.begin(), s.end());
    return s;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);

    int val; cin >> hex >> val;

    string bi = change_base(val, 2);
    cout << bi << endl << oct << val;
    return 0;
}