Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Buslnwzuz
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-10 00:26:46
#include <bits/stdc++.h>
using namespace std;
int toten(string a){
int total=0;
int ch;
for(char num:a){
if(num>='0'&&num<='9') ch = num-'0';
else if(num>='A'&&num<='F') ch = num - 'A'+10;
total = total*16 + ch;
}
return total;
}
void to_other(int a,int base){
vector<int> k;
int j=a;
while(j!=0){
k.push_back(j%base);
j/=base;
}
reverse(k.begin(),k.end());
for(int i=0;i<k.size();i++){
cout << k[i];
}
cout << endl;
}
int main(){
string a;
cin >> a;
int c = toten(a);
to_other(c,2);
to_other(c,8);
return 0;
}