#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,sum=0;
string x,s="";
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> x >> m;
for(int i=0;i<x.size();i++)
{
if(x[i]<'A')
{
sum+=(x[i]-'0')*pow(n,x.size()-i-1);
}
else
{
sum+=(x[i]-'A'+10)*pow(n,x.size()-i-1);
}
}
while(sum)
{
if(sum%m<10)
{
s+=sum%m+'0';
}
else
{
s+=sum%m+'A'-10;
}
sum/=m;
}
reverse(s.begin(),s.end());
cout << s << endl;
return 0;
}
来源:CSDN
作者:AimerAimerAimer
链接:https://blog.csdn.net/qq_43032263/article/details/104792940