提交时间:2024-08-19 20:56:08
运行 ID: 167935
#include<iostream> using namespace std; int main() { string w="01234546789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string a,b; int x[110],y[110],i,k,N; cin>>N>>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); return 0; }