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.
Input
The 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 tt consisting 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.
Output
Print one string consisting exactly of kk lowercase Latin letters — the median (the middle element) of list of strings of length kklexicographically not less than ss and not greater than tt.
Examples
input
Copy
2
az
bf
output
Copy
bc
input
Copy
5
afogk
asdji
output
Copy
alvuw
input
Copy
6
nijfvj
tvqhwp
output
Copy
qoztvz
题意:给出以字符串为端点的两个字符串[str1,str2],求字典序在区间最中间那个字符串。
思路:模拟26位加法与除法
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxm = 300005;
int main()
{
int n;
char a[maxm],b[maxm];
cin>>n;
cin>>a>>b;
int c[maxm]={0};
int fg = 0;
for(int i = n-1;i>=0;i--)///加法
{
int s = (a[i]-'a')+( b[i]-'a')+fg;
if(s>=26 && i!=0)
{
s-=26;
fg = 1;
}else fg = 0;
c[i] = s;
}
for(int i = 0; i<n;i++)///除法
{
if(c[i]%2)c[i+1]+=26;
c[i]/=2;
}
for(int i = 0; i<n;i++)cout<<(char)(c[i]+'a');
cout<<endl;
return 0;
}