Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: nicekrittaphat
Problemset: แปลงเลขฐาน
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-11 14:59:39
#include<iostream>
#include<cmath>
using namespace std;
int result = 0;
string result2 = "";
int change16to10(string haxe){
result = 0;
for(int i=0;i<haxe.size();i++){
if(haxe[i]-'0'<=9){
result += pow(16,haxe.size()-i-1)*(haxe[i]-'0');
}
else{
result+= pow(16,haxe.size()-i-1)*(haxe[i]-'A'+10);
}
}
return result;
}
string change10toother(int start,int base){
result2 = "";
while(start>0){
char add = (start%base)+'0';
result2 = add+result2;
start/=base;
}
return result2;
}
int main(){
string base16;
cin>>base16;
int base10 = change16to10(base16);
cout<<change10toother(base10,2)<<endl;
cout<<change10toother(base10,8);
return 0;
}