提交时间:2023-08-21 16:06:26
运行 ID: 99002
#include<iostream> #include<stack> using namespace std; int main(){ int n,m; string s; long long h=0; cin>>n>>s>>m; for(int i=0;i<s.size();i++){ if(s[i]>='0'&&s[i]<='9'){ h=h*n+s[i]-'0'; } else{ h=h*n+s[i]-'A'+10; } } stack <char>jz; while(h){ if(h%m>=10){ jz.push((h%m)-10+'A'); } else{ jz.push((h%m)+'0'); } h/=m; } while(!jz.empty()){ cout<<jz.top(); jz.pop(); } }