Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: chs_14
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.003 second
Submitted On: 2025-11-29 14:02:07
#include <bits/stdc++.h>
using namespace std;
string base_convert(int num, int base) {
if (num == 0) return "0";
string num_base;
while (num>0)
{
num_base+=(num%base + '0');
num/=base;
}
reverse(num_base.begin(), num_base.end());
return num_base;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
string num_16, num_2, num_8;
cin >> num_16;
int num_10 = stoi(num_16, nullptr, 16);
num_2 = base_convert(num_10, 2);
num_8 = base_convert(num_10, 8);
cout << num_2 << '\n';
cout << num_8 << '\n';
return 0;
}