#include <bits/stdc++.h>

using namespace std;

//****
string HexToBin(string hexdec)
{
	long int i = 0;
    string ans;
	while (hexdec[i]) {

		switch (hexdec[i]) {
		case '0':
			ans+="0000";
			break;
		case '1':
            ans+="0001";
			break;
		case '2':
            ans+="0010";
			break;
		case '3':
            ans+="0011";
			break;
		case '4':
            ans+="0100";
			break;
		case '5':
            ans+="0101";
			break;
		case '6':
            ans+="0110";
			break;
		case '7':
            ans+="0111";
			break;
		case '8':
            ans+="1000";
			break;
		case '9':
            ans+="1001";
			break;
		case 'A':
		case 'a':
            ans+="1010";
			break;
		case 'B':
		case 'b':
            ans+="1011";
			break;
		case 'C':
		case 'c':
            ans+="1100";
			break;
		case 'D':
		case 'd':
            ans+="1101";
			break;
		case 'E':
		case 'e':
            ans+="1110";
			break;
		case 'F':
		case 'f':
            ans+="1111";
			break;
		}
		i++;
	}
return ans;
}

//****

int main()
{
    string a,s;
    cin>>s;
    for(int i=0;i<11;i++){
        if(s[i]!='.')
        a.push_back(s[i]);
    }
    
    map<string,char> table;
    
    table.insert({"110001000101",'A'});
    table.insert({"1100010001011110",'B'});
    table.insert({"110001000110",'C'});
    table.insert({"11000100011010",'D'});
    table.insert({"1",'E'});
    table.insert({"01",'F'});
    table.insert({"00",'G'});
    
    // for(auto it=table.begin();it!=table.end();it++){
    //     cout<<it->first<<" "<<it->second<<endl;
    // }
    
    // cout<<a<<endl;
    // cout<<HexToBin(a)<<endl;
    string s1=HexToBin(a);
    cout<<s1<<endl;
    map<int,char> v;
    
    for(auto it=table.begin();it!=table.end();it++){
        bool flag = true;
        int l=it->first.size();
        for(int i=0;i<l;i++){
            if(s1[i]!=it->first[i]){
                flag = false;
                break;
            }
        }
        if(flag){
            v.insert({l,it->second});
        }
    }
    char ans;
    auto it1 = v.rbegin();
    ans = it1->second;
    cout<<ans<<endl;
    

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: