分析:码农题,照这模拟就行,高精度的B进制,注意字符串反转的技巧。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
char s[]={'','','','','','','','','','','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int n; //进制
int vis1[maxn],vis2[maxn];
int ans[maxn];
int main()
{
while(cin>>n)
{
string a,b;
cin>>a;
cin>>b;
memset(vis1,,sizeof(vis1));
memset(vis2,,sizeof(vis2));
int len1=a.length(); //反转第一个串
for(int i=;i<len1/;i++){
char temp=a[i];
a[i]=a[len1--i];
a[len1--i]=temp;
}
for(int i=;i<len1;i++){
int pos;
for(int j=;j<;j++){
if(a[i]==s[j]){
pos=j; break;
}
}
vis1[i]=pos;
}
int len2=b.length(); //反转第二个串
for(int i=;i<len2/;i++){
char tt=b[i];
b[i]=b[len2-i-];
b[len2--i]=tt;
}
for(int i=;i<len2;i++){
int pos;
for(int j=;j<;++j){
if(b[i]==s[j]){
pos=j; break;
}
}
vis2[i]=pos;
}
int mx=max(len1,len2);
int cnt=;
for(int i=;i<mx;i++){
int temp=vis1[i]+vis2[i]+cnt;
if(temp>=n){
cnt=;
ans[i]+=temp%n;
}else{
cnt=;
ans[i]+=temp;
}
}
if(cnt==){
ans[mx]=; ++mx;
}
string ss;
for(int i=;i<mx;i++){
ss+=s[ans[i]];
}
for(int i=;i<mx/;i++){
char yy=ss[i];
ss[i]=ss[mx-i-];
ss[mx-i-]=yy;
}
cout<<ss<<endl;
}
return ;
}
04-30 04:30