Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: kkxkkx001
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.003 second
Submitted On: 2026-10-10 11:01:33
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string basen(int n,int base10){
string base2="";
int temp2 = base10;
while (temp2>0){
int temp=temp2%n;
temp2=temp2/n;
string temp3=to_string(temp);
base2+=temp3;
}
reverse(base2.begin(),base2.end());
return base2;
}
int main(){
string base16;
cin >> base16;
int base10=0;
for (char i:base16){
if (i-55 <4){
int temp = i-'0';
base10 = base10*16+temp;
}
else{
int temp = i-55;
base10 = base10*16+temp;
}
}
cout << basen(2,base10) << endl;
cout << basen(8,base10) << endl;
}