提交时间:2023-08-21 16:25:31

运行 ID: 99037

#include<bits/stdc++.h> using namespace std; int a[21],i,j,p,n,q,s; int main(){ while(cin >>p>>n>>q){ j=21; while(n>0){ j=j-1; a[j]=n%10; n/=10; } s=0; for(int i=j;i<=20;++i){ s=s*p+a[i]; } j=21; while(s>0){ j-=1; a[j]=s%q; s/=q; } for(int i=j;i<=20;i++){ if(a[i]>9){ cout <<char(a[i]-10+'A'); }else{ cout <<a[i]; } } cout <<endl; } return 0; }