Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: 38408

Problemset: เลขหลักของผลคูณ

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-15 15:34:37

#include<bits/stdc++.h>
using namespace std;
int main(){
    string word;
    cin >> word;
    int tran = 0;
    string numtwo;
    string numeg;
    for (int i = 0; i < word.size(); i++)
    {
        int num = word[i];
        if(word[i]>='A'&&word[i]<='Z'){
            tran += (num -'A'+10)*pow(16,word.size()-1-i);
        }else{
            tran += (num -'0')*pow(16,word.size()-1-i);
        }
    }
    int x = tran;
    while (x>0)
    {
        numtwo+=to_string(x%2);
        x/=2;
    }
    while (tran>0)
    {
        numeg+=to_string(tran%8);
        tran/=8;
    }
    reverse(numtwo.begin(),numtwo.end());
    reverse(numeg.begin(),numeg.end());
    cout << numtwo << "\n" << numeg;
    
}