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 kk lexicographically not less than ss and not greater than tt.

Examples

Input
2
az
bf
Output
bc
Input
5
afogk
asdji
Output
alvuw
Input
6
nijfvj
tvqhwp
Output
qoztvz

题意:给你两个只含有小写字母的字符串, s和t,保证s的字典序比t小。把s和t看成一个26进制的数,让你输出这两个数的中位数。

思路:首先把两个字符串的每一个位上的数值加起来,然后向前进位。
然后从头开始遍历加起来的那个数值,如果数值为偶数,那么中位数的这一位就是数值/2,如果是奇数,那么中位数的这一位是/2且向下取整。
并把那个多余的一加到下一位中,(注意上一位的1到下一位是26),最后输出答案即可。 *(主要是通过咱们熟悉的十进制来找到转换的规律,然后处理。)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int a[maxn];
int b[maxn];
int main()
{
// freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
// freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
gbtb;
// repd(i,0,25)
// {
// cout<<(char)('a'+i)<<" ";
// }
string xia;
string shang;
int k;
cin>>k>>xia>>shang;
for(int i=k-;i>=;i--)
{
// a[i-1]+=(shang[i]+xia[i]-'a'-'a')/26;
a[i]+=(shang[i]+xia[i]-'a'-'a');
}
for(int i=k-;i>;i--)
{
a[i-]+=a[i]/;
a[i]%=;
}
// repd(i,0,k)
// {
// db(a[i]);
// }
for (int i = ; i < k; ++i)
{
if(a[i]&)
{
a[i+]+=;;
b[i]=a[i]/;
}else
{
b[i]=a[i]/;
}
}
for (int i = ; i < k; ++i)
{
cout<<(char)(b[i]+'a');
/* code */
}
cout<<endl;
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}

Median String CodeForces - 1144E的更多相关文章

  1. Codeforces Round #550 (Div. 3) E. Median String (模拟)

    Median String time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  2. Minimal string CodeForces - 797C

    Minimal string CodeForces - 797C 题意:有一个字符串s和空串t和u,每次操作可以将s的第一个字符取出并删除然后放到t的最后,或者将t的最后一个字符取出并删除然后放到u的 ...

  3. E. Median String 解析(思維、大數運算)

    Codeforce 1144 E. Median String 解析(思維.大數運算) 今天我們來看看CF1144E 題目連結 題目 給你兩個長度為\(k\)的字串\(s\)和\(t\),求字典序排序 ...

  4. Codeforces 1144 E. Median String

    原题链接:https://codeforces.com/problemset/problem/1144/E tag:字符串模拟,大整数. 题意:给定两个字符串,求字典序中间串. 思路:可以把这个题当做 ...

  5. Codeforces Round #550 (Div. 3)E. Median String

    把字符串看作是26进制的数,从后往前翻译,那么就可以把两个串变成对应的26进制的数字,那么只要把两个数加起来除以二就得到中间的串对应的数了,同理再转化回来就行了.但是这样会有一个问题就是串的长度有2e ...

  6. Codeforces Round #550 (Div. 3) E. Median String (思维,模拟)

    题意:给你两个字符串\(s\)和\(t\),保证\(t\)的字典序大于\(s\),求他们字典序中间的字符串. 题解:我们假设题目给的不是字符串,而是两个10禁止的正整数,那么输出他们之间的数只要把他两 ...

  7. D. Mahmoud and Ehab and the binary string Codeforces Round #435 (Div. 2)

    http://codeforces.com/contest/862/problem/D 交互题 fflush(stdout) 调试: 先行给出结果,函数代替输入 #include <cstdio ...

  8. You Are Given a Decimal String... CodeForces - 1202B [简单dp][补题]

    补一下codeforces前天教育场的题.当时只A了一道题. 大致题意: 定义一个x - y - counter :是一个加法计数器.初始值为0,之后可以任意选择+x或者+y而我们由每次累加结果的最后 ...

  9. Check the string CodeForces - 960A

    A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend ...

随机推荐

  1. c/c++链队列

    链队列 链队列就是简化了的单链表 nodequeue.h #ifndef __NODEQUEUE__ #define __NODEQUEUE__ #include <stdio.h> #i ...

  2. VS快捷键失效问题

    VS作为宇宙最强IDE,为我们提供了强大的快捷键组合,熟练的使用这些快捷键能极大提高我们的编码效率,但是在我们实际使用的过程中经常会遇到某个快捷键组合失效的问题. 问题原因: 一般都是VS的快捷键与电 ...

  3. LeetCode算法题-Factorial Trailing Zeroes(Java实现)

    这是悦乐书的第183次更新,第185篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第42题(顺位题号是172).给定一个整数n,返回n!中的尾随零数.例如: 输入:3 输 ...

  4. Markdown语法大全

    目录 前言: 1.Markdown基础用法 1.1 目录 1.2 标题 1.3 字体样式 1.4 引用 1.5 图片 1.6 超链接 1.7 列表 1.8 表格 1.9 代码 1.10 流程图 1.1 ...

  5. Python开发【第三篇】:函数&读写文件

    三元运算 三元运算,是条件语句的简单的写法.如果条件为真,则返回值1,否则,返回值2. ret = 值1 if 条件 else 值2 深浅拷贝 对于数字(int)和字符串(str)而言,赋值.深拷贝. ...

  6. WPF自定义控件(二)の重写原生控件样式模板

    话外篇: 要写一个圆形控件,用Clip,重写模板,去除样式引用圆形图片可以有这三种方式. 开发过程中,我们有时候用WPF原生的控件就能实现自己的需求,但是样式.风格并不能满足我们的需求,那么我们该怎么 ...

  7. 浅析 PHP 中的 Generator

    浅析 PHP 中的 Generator Miss Wang php开发案例 前天 何为 Generator 从 PHP 5.5 开始,PHP 加入了一个新的特性,那就是 Generator,中文译为生 ...

  8. tensorflow中的Supervisor

    tf.train.Supervisor()可以帮我们简化一些事情,可以保存模型参数和Summary,它有以下的作用: 1)自动去checkpoint加载数据或初始化数据 ,因此我们就不需要手动初始化或 ...

  9. Python中的单例模式——装饰器实现剖析

    Python中单例模式的实现方法有多种,但在这些方法中属装饰器版本用的广,因为装饰器是基于面向切面编程思想来实现的,具有很高的解耦性和灵活性. 单例模式定义:具有该模式的类只能生成一个实例对象. 先将 ...

  10. Android 6.0以后的版本报错:open failed: EACCES (Permission denied)

    Android 6.0以后的版本报错:open failed: EACCES (Permission denied) 在开发项目中,遇见要进行文件操作,遇见Caused by: android.sys ...