You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than tt.Let’s consider list of all strings consisting of exactly kk lowercase Latin letters, lexicographically not less than ss and not greater than tt (including ss and tt) in lexicographical order. For example, for k=2k=2, s=s=“az” and t=t=“bf” the list will be [“az”, “ba”, “bb”, “bc”, “bd”, “be”, “bf”].Your task is to print the median (the middle element) of this list. For the example above this will be “bc”.It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.InputThe first line of the input contains one integer kk (1≤k≤2⋅1051≤k≤2⋅105) — the length of strings.The second line of the input contains one string ss consisting of exactly kk lowercase Latin letters.The third line of the input contains one string ttconsisting of exactly kk lowercase Latin letters.It is guaranteed that ss is lexicographically less than tt.It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.OutputPrint one string consisting exactly of kklowercase Latin letters — the median (the middle element) of list of strings of length kklexicographically not less than ss and not greater than t.
Examples
Input
2
az
bf
Output
bc
Input
5
afogk
asdji
Output
alvuw
Input
6
nijfvj
tvqhwp
Output
qoztvz
这题很坑,转26进制吧,注意进位和余数的处理,代码实现(补题成功,吸收大佬的思想)
#include<cstdio>
#include<cstring>
int main(){
int n;
char a[20005],b[20005];
int ans[20005];
scanf("%d",&n);
scanf("%s%s",a,b);
int x,y;
for(int i=n-1;i>=0;i--){
x=a[i]-'a';
y=b[i]-'a';
if(y-x<0){
b[i-1]--;
y+=26;
}
if((y-x)%2==0){
ans[i]=(y-x)/2;
}
else{
ans[i]=(y-x)/2;
ans[i+1]+=13;
}
}
for(int i=n-1;i>=0;i--){
x=a[i]-'a';
ans[i-1]+=(x+ans[i])/26;
ans[i]=(x+ans[i])%26;
}
for(int i=0;i<n;i++){
printf("%c",'a'+ans[i]);
}
printf("\n");
return 0;
}