Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Peerawat
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.004 second
Submitted On: 2026-09-27 12:45:37
#include <bits/stdc++.h>
using namespace std;
string toBase(int ten,int n){
if(ten==0){
return "0";
}
string result="";
while(ten>0){
int r = ten%n;
result+= to_string(r);
ten /= n;
}
reverse(result.begin(),result.end());
return result;
}
int main(){
string in;
cin >> in;
int ten;
ten = stoi(in,nullptr,16);
string two = toBase(ten,2);
string eight = toBase(ten,8);;
cout << two << endl;
cout << eight;
}