Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: 38408
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 10:02:34
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
string a ;
int b=0;
int c=0;
int d = 0;
int f = 0;
cin >> a ;
for (int i = 0; i < a.length(); i++)
{
if(a[i]>='A'&&a[i]<='F'){
b += (a[i]-'A'+10)*pow(16,a.length()-i-1);
c += (a[i]-'A'+10)*pow(16,a.length()-i-1);
}else{
b += (a[i]-'0')*pow(16,a.length()-i-1);
c += (a[i]-'0')*pow(16,a.length()-i-1);
}
}
string answer;
string answer1;
while (b>0)
{
int n = b %2;
answer+=n+'0';
b/=2;
}
while (c>0)
{
int n = c %8;
answer1+=n+'0';
c/=8;
}
reverse(answer1.begin(),answer1.end());
reverse(answer.begin(),answer.end());
cout<<answer<<"\n"<<answer1;
}