题解 | 进制转换
#include <iostream> using namespace std; using ll_t = long long; ll_t toDex(const string& str){ string hex_num_str = str.substr(2); ll_t sum = 0; for (char ch : hex_num_str) { if (ch >= 'A' && ch <= 'F') { sum = sum*16 + ch - 'A' + 10; } else { sum = sum*16 + ch - '0'; } } return sum; } int main() { string hex; cin >> hex; ll_t num = toDex(hex); cout << num << endl; return 0; } // 64 位输出请用 printf("%lld")