把字符串看作是26进制的数,从后往前翻译,那么就可以把两个串变成对应的26进制的数字,那么只要把两个数加起来除以二就得到中间的串对应的数了,同理再转化回来就行了。
但是这样会有一个问题就是串的长度有2e5,26的2e5次方显然不可求,所以需要对每一位进行手动的加和运算。
对于两个串,我们假设a串从后往前的每一位对应的数值为a0, a1, a2...,b串从后往前的每一位对应的数值为b0, b1, b2...对于进制加法,有

扔一下垃圾代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define ll long long
#define lowbit(x) (x&(-x))
#define PI acos(-1)
#define ms(x,y) memset(x, y, sizeof(x))
using namespace std; const int maxn = 2e5+7;
char a[maxn], b[maxn]; int ans[maxn]; int main()
{
int n;
scanf("%d", &n);
scanf("%s%s", a, b); for(int i=n-1;i>=0;i--)
{
int ta = a[i] - 'a';
int tb = b[i] - 'a';
ans[i] = ta + tb; if(ans[i]&1)
{
ans[i+1] += 13;
ans[i] = (ans[i] - 1) / 2;
ans[i] += ans[i+1] / 26;
ans[i+1] %= 26;
}
else ans[i] = ans[i] / 2;
} for(int i=0;i<n;i++) printf("%c", 'a' + ans[i]); puts("");
}

  

Codeforces Round #550 (Div. 3)E. 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. Codeforces Round #550 (Div. 3) E. Median String (思维,模拟)

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

  3. 贪心 Codeforces Round #303 (Div. 2) B. Equidistant String

    题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #includ ...

  4. CodeForces Round #550 Div.3

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

  5. Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律

    C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...

  6. Codeforces Round #354 (Div. 2)_Vasya and String(尺取法)

    题目连接:http://codeforces.com/contest/676/problem/C 题意:一串字符串,最多改变k次,求最大的相同子串 题解:很明显直接尺取法 #include<cs ...

  7. Codeforces Round #303 (Div. 2) B. Equidistant String 水题

    B. Equidistant String Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/54 ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. Codeforces Round #604 (Div. 2) A. Beautiful String

    链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...

随机推荐

  1. Linux 大规模请求server连接数相关设置

    一般一个大规模Linuxserver请求数可能是几十万上百万的情况.须要足够的连接数来使用,所以务必进行对应的设置. 默认的Linuxserver文件描写叙述符等打开最大是1024.用ulimit - ...

  2. Oracle EBS LOV速度优化

    一.现象 本文地址:http://blog.csdn.net/sunansheng/article/details/50952758 当我们的EBS LOV的SQL写得比較复杂.或者数据量比較多时,L ...

  3. Fragment进阶(四)-----&gt;參数传递3种写法

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  4. luogu1357 花园 状态压缩 矩阵快速幂

    题目大意 小L有一座环形花园,沿花园的顺时针方向,他把各个花圃编号为1~N(2<=N<=10^15).他的环形花园每天都会换一个新花样,但他的花园都不外乎一个规则,任意相邻M(2<= ...

  5. hdu 6082 度度熊与邪恶大魔王(2017"百度之星"程序设计大赛 - 资格赛 )

    度度熊与邪恶大魔王 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  6. hdu1150——最小点覆盖

    As we all know, machine scheduling is a very classical problem in computer science and has been stud ...

  7. springboot的登录拦截机制

    转自:https://blog.csdn.net/qq_26555463/article/details/78296103 如果是一个后台的管理项目的,有些东西是不能直接就可以访问的,必须要登录才可以 ...

  8. Spring Data 自动生成

    之前一直用的mybatis逆向自动生成,由于最近学习springdata,所以看了一下springdata的自动生成,基本与mybatis一致,不同的也许就是逆向生成代码(实体类,mapper等)和正 ...

  9. android开发 设备调试问题

    如果在mac下面用趁机开发android程序,发现不能连接上时就需要进行简单设置即可 先设置Finder为可以显示所有隐藏文件夹: 打开终端,输入如下命令: 显示Mac隐藏文件的命令:defaults ...

  10. RabbitMQ 官方NET教程(四)【路由选择】

    在上一个教程中,我们构建了一个简单的日志记录系统. 我们能够广播日志消息给所有你的接收者. 在本教程中,我们将为其添加一个功能 - 我们将让日志接收者可以仅订阅一部分消息. 例如,我们将能够仅将关键的 ...