Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: SonnyHappy108
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.002 second
Submitted On: 2026-07-18 10:47:30
#include <bits/stdc++.h>
using namespace std;
int main(){
string a;
long long q=0;
cin >> a;
int b=a.length();
for(int i=b-1;i>=0;i--){
if(a[b-1-i]>='A'){
q+=pow(16,i)*(a[b-1-i]-55);
}
else{
q+=pow(16,i)*(a[b-1-i]-'0');
}
}
string c="";
long long p=q;
while(p!=0){
c.push_back(p%2+'0');
p/=2;
}
reverse(c.begin(),c.end());
cout << c << "\n";
p=q;
c="";
while(p!=0){
c.push_back(p%8+'0');
p/=8;
}
reverse(c.begin(),c.end());
cout << c;
}