Submission
Status:
P-PPPPPPPP
Subtask/Task Score:
90/100
Score: 90
User: Nuttykub
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-01 16:09:26
#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;
ll total = 0;
int a = s.length()-1;
for (ll i =0;i < s.length();i++){
if (s[i]-'A' >= 0) total= total+((s[i]-'A'+10)*pow(16,a));
else total = total+((s[i]-'0')*pow(16,a));
a--;
}
int for_2 = total;
int for_8 = total;
string ans_2 = "";
string ans_8 = "";
while(true){
ans_2+=to_string(for_2%2);
for_2/=2;
if (for_2<2){
ans_2+=to_string(for_2%2);
break;
}
}
while(true){
ans_8+=to_string(for_8%8);
for_8/=8;
if (for_8<8){
ans_8+=to_string(for_8%8);
break;
}
}
reverse(ans_2.begin(),ans_2.end());
reverse(ans_8.begin(),ans_8.end());
cout << ans_2 << endl << ans_8;
}