Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Newton4566

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-13 21:04:47

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

std::string toBase(unsigned long long n, int base) {
    const char* d = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    char buf[65];
    int i = 64;
    buf[i] = '\0';
    do {
        buf[--i] = d[n % base];
        n /= base;
    } while (n);
    return buf + i;
}

int main() {
    string input;
    cin >> input;

    int decimal = stoull(input, nullptr, 16);

    cout << toBase(decimal, 2) << '\n' << toBase(decimal, 8) << '\n';

    return 0;
}