//土尔逊Torson 编写于2023/5/04 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <string> #include <vector> using namespace std; char IntToChar(int x) { //数字转字符 if (x < 10) { return x + '0'; } else { return x - 10 + 'a'; } } int CharToInt(char c) { //字符转数字 if (c >= '0' && c <= '9') { return c - '0'; } else { return c - 'A' + 10; } } int main() { int m, n; scanf("%d%d", &m, &n); string str; cin >> str; long long number = 0; for (int i = 0; i < str.size(); ++i) { //m进制转十进制 number *= m; number += CharToInt(str[i]); } vector<char> answer; while (number != 0) { //十进制转n进制 answer.push_back(IntToChar(number % n)); number /= n; } for (int i = answer.size() - 1; i >= 0; --i) { //逆序输出 printf("%c", answer[i]); } printf("\n"); system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")