提交时间:2024-08-19 20:57:23
运行 ID: 167939
#include<iostream> using namespace std; int main() { string w="01234546789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string a,b; int x[110],y[110],i,k,N; cin>>N; for(int i=0;i<=N-1;i++) { if(i<10) w=w+char(i+48); else w=w+char(55+i); } cin>>a>>b; while(a.length()<b.length()) a='0'+a; while(b.length()<a.length()) b='0'+b; a='0'+a; b='0'+b; for(i=a.length()-1;i>=0;i--) { x[i]=w.find(a[i],0); y[i]=w.find(b[i],0); } for(i=a.length()-1;i>=0;i--) { x[i]=x[i]+y[i]; if(x[i]>=N) { k=i; while(x[k]>=N) { x[k]=x[k]-N; x[k-1]++; k--; } } } for(i=a.length()-1;i>=0;i--) a[i]=w[x[i]]; while(a[0]=='0') a.erase(0,1); cout<<(a.length()==0?"0":a)<<endl; return 0; }