#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1e5+50;
const int M=1e5+50;
const int Mod=1e9+7;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int n;
int v[N];
// string s1,s2;
char s1[N],s2[N];
char c1[N],c2[N];
char ans[N];
int to(char x){
if(x>='0'&&x<='9') return x-'0'; else return x-'A'+10;
}
char ot(int x){
if(x>=0&&x<=9) return x+'0'; else return x-10+'A';
}
int main()
{
n=read();
for(int i=0;i<n;++i) v[i]=read(),c1[i]='0',c2[i]='0';
cin>>s1>>s2;
int l1=strlen(s1)-1;
int l2=strlen(s2)-1;
for(int i=0;i<=l1;++i) c1[l1-i]=s1[i];
for(int i=0;i<=l2;++i) c2[l2-i]=s2[i];
// for(int i=0;i<n;++i) cout<<c1[i];
// for(int i=0;i<n;++i) cout<<c2[i];
for(int i=0;i<n;++i){
ans[i]='0';
int _=to(c1[i])+to(c2[i]);
// cout<<c1[1]<<" "<<c2[1]<<endl;
// cout<<_<<endl;
c1[i+1]+=_/v[i];
ans[i]=ot(_%v[i]);
}
bool f=0;
for(int i=n-1;i>=0;--i){
if(ans[i]=='0'&&!f) continue;
if(ans[i]!='0') f=1;
printf("%c",ans[i]);
}
printf("\n");
return 0;
}
标签:ch,const,int,printf,&&,ans,2022.10
From: https://www.cnblogs.com/R-V-G/p/16748703.html