题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
int main() {
unordered_map<char,int> map;
map['A'] = 10;
map['B'] = 11;
map['C'] = 12;
map['D'] = 13;
map['E'] = 14;
map['F'] = 15;
string str1;
getline(cin,str1);
str1 = str1.substr(2,str1.size() - 2);
long long res = 0l;
int i = 0;
for(auto it = str1.rbegin(); it != str1.rend(); it++,i++){
if(!isdigit(*it)){
res += map[*it]*pow(16,i);
}else {
res += (*it - '0') * pow(16,i);
}
}
cout << res << endl;
return 0;
}
// 64 位输出请用 printf("%lld")

