Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Patn01Z

Problemset: แปลงเลขฐาน

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-27 21:55:16

#include <iostream>
#include <cmath>
using namespace std;

int main(){
    string N;
    cin >> N;
    int N_l = N.length();
    int n=0;
    string n1="";
    string n2="";
    for(int i=0;i<N_l;++i){
        char temp=N[i];
        if(((47<temp)&&(temp<58))){
            n+=(N[i]-48)*pow(16,N_l-1-i);
        }
        else{
            n+=(N[i]-55)*pow(16,N_l-1-i);
        }
    }
    
    for(int temp=n;temp>0;){
        n1=char((temp%2)+48)+n1;
        temp=temp/2;
    }
    cout << n1 << endl;
    
    for(int temp=n;temp>0;){
        n2=char((temp%8)+48)+n2;
        temp=temp/8;
    }
    cout << n2 << endl;
}