提交时间:2024-08-20 14:40:18

运行 ID: 168913

#include <bits/stdc++.h> using namespace std; int main(){ string a,b,w; int x[100],y[100],i,k,N; cin>>N; for(i=0;i<=N-1;i++){ if(i<10) w=w+char(48+i); 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<<endl; return 0; }