Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chokun

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-06 13:57:45

#include <bits/stdc++.h>
using namespace std;

int main() {
    string hex_input;
    if (!(cin >> hex_input)) return 0;

    int number = stoi(hex_input, nullptr, 16);

    if (number == 0) {
        cout << 0 << endl;
    } else {
        string binary_str = bitset<16>(number).to_string();
        
        size_t first_one = binary_str.find('1');
        if (first_one != string::npos) {
            cout << binary_str.substr(first_one) << endl;
        }
    }

    cout << oct << number << endl;

    return 0;
}