#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; cin>>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){ answer.push_back(IntToChar(number%n)); //十进制转m进制 number/=n; } for(int i=answer.size()-1;i>=0;--i){ //逆序输出 cout<<answer[i]; } return 0; }