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)。
 1 #include<cstdio>
2 #include<iostream>
3 #include<cstdlib>
4 #include<cstring>
5 #include<cmath>
6 #include<algorithm>
7 using namespace std;
8 int main()
9 {
10 int n;
11 char str1[200005],str2[200005];
12 int a[200005];
13 scanf("%d",&n);
14 cin.get();
15 scanf("%s",str1);
16 cin.get();
17 scanf("%s",str2);
18 int flag=0;
19 for(int i=n-1;i>=0;i--)
20 {
21 int sum=str1[i]-'a'+str2[i]-'a'+flag;//flag做标记,进行满26进一
22 if(sum>=26&&i!=0)//第一位不用进一,到时候直接除以二就行
23 {
24 flag=1;
25 a[i]=sum-26;
26 }
27 else {
28 flag=0;
29 a[i]=sum;
30 }
31 }
32 for(int i=0;i<n;i++)
33 if(a[i]%2)
34 {
35 a[i+1]=a[i+1]+26;
36 a[i]/=2;
37 }
38 else
39 a[i]/=2;
40 for(int i=0;i<n;i++)
41 printf("%c",a[i]+'a');
42 printf("\n");
43 return 0;
44 }

Median String的更多相关文章

  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. E. Median String 解析(思維、大數運算)

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

  3. Median String CodeForces - 1144E

    You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is le ...

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

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

  5. Codeforces 1144 E. Median String

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

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

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

  7. CodeForces Round #550 Div.3

    http://codeforces.com/contest/1144 A. Diverse Strings A string is called diverse if it contains cons ...

  8. CF550 DIV3

    A - Diverse Strings CodeForces - 1144A A string is called diverse if it contains consecutive (adjace ...

  9. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  10. Google 面试题:Java实现用最大堆和最小堆查找中位数 Find median with min heap and max heap in Java

    Google面试题 股市上一个股票的价格从开市开始是不停的变化的,需要开发一个系统,给定一个股票,它能实时显示从开市到当前时间的这个股票的价格的中位数(中值). SOLUTION 1: 1.维持两个h ...

随机推荐

  1. Kubernetes(K8S) 配置管理-ConfigMap 介绍

    作用:存储不加密数据到 etcd,让 Pod 以变量或者 Volume 挂载到容器中 场景:配置文件 创建配置文件 redis.properties redis.host=127.0.0.1 redi ...

  2. 爬虫笔记之xpath

    目录 xpath如何取包含多个class属性 xpath获取当前标签下的所有文本(包括子标签) xpath如何取包含多个class属性 如果HTML结构是这样 <div class=" ...

  3. Kettle:跨库(SQLServer->PostgreSQL)同步多张表数据的详细设计过程

    〇.参考地址 1.多个Excel实现同步 https://www.wangt.cc/2021/05/kettle%E5%A4%9A%E4%B8%AA%E8%A1%A8%E4%B8%80%E8%B5%B ...

  4. Kafka教程(二)API开发-生产者、消费者、topic

    一.地址 1.实时更新的思维导图 https://www.mubucm.com/doc/4uqlpedefuj 2.图片 二.具体内容   5.producer生产者   demo   发送pro.s ...

  5. 常用函数/异常处理/for循环本质

    常用内置函数 1,map() - 映射 格式: map(函数,可遍历对象) 指将遍历的元素挨个取出来做函数的行参传参,得到的返回值全部放回map工厂中,map工厂可以被转换成列表查看到 每一个被函数处 ...

  6. 微软宣布 S2C2F 已被 OpenSSF 采用

    开源供应链安全对大多数 IT 领导者来说是个日益严峻的挑战,围绕确保开发人员在构建软件时如何使用和管理开源软件 (OSS) 依赖项的稳健策略至关重要.Microsoft 发布安全供应链消费框架 (S2 ...

  7. websockets的原理

    一.应用场景 http 协议 客户端发起请求的时候才会返回内容,如果要处理类似于聊天室的应用,需要客户端不间断的发起请求(轮询),非常占用服务器的性能.所以websocket出现了. 二.ws(wss ...

  8. 编译安装nmon

    nmon 是什么? nmon(Nigel's performance Monitor for Linux)是一种Linux性能监视工具,当前它支持 Power/x86/x86_64/Mainframe ...

  9. GitHub - 电脑经常无法访问GitHub页面

    来自这里 1.打开Dns检测|Dns查询 - 站长工具2.在检测输入栏中输入http://github.com官网3.把检测列表里的TTL值最小的IP输入到host里,并对应写上github官网域名. ...

  10. 一步步教你在Edge浏览器上安装网风笔记

    微软于2022年6月15日正式结束对浏览器"Internet Explorer (IE)"的支持,IE已正式退出历史舞台,取而代之的是目前风头正盛的被微软称为当今最好用的Edge浏 ...