Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Nuttykub
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-01 16:20:38
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
if (s == "0"){
cout << 0 << endl << 0;
return 0;
}
ll total = 0;
int a = s.length()-1;
for (ll i =0;i < s.length();i++){
int digit = isdigit(s[i])? s[i]-'0' : toupper(s[i]) - 'A' +10;
total = total*16+digit;
}
int for_2 = total;
int for_8 = total;
string ans_2 = "";
string ans_8 = "";
while(for_2>0){
ans_2 += char('0'+for_2%2);
for_2/=2;
}
while(for_8>0){
ans_8 += char('0'+for_8%8);
for_8/=8;
}
reverse(ans_2.begin(),ans_2.end());
reverse(ans_8.begin(),ans_8.end());
cout << ans_2 << endl << ans_8;
}