Codeforces Round #550 (Div. 3)E. Median String
把字符串看作是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("");
}
转载于:https://www.cnblogs.com/HazelNut/p/10634221.html
Codeforces Round #550 (Div. 3)E. Median String相关推荐
- Codeforces Round #656 (Div. 3) D. a-Good String
Codeforces Round #656 (Div. 3) D. a-Good String 题目链接 You are given a string s[1-n] consisting of low ...
- Codeforces Round 550 (Div.3) 题解
目录 A.DiverseStringsA.\ Diverse\ StringsA. Diverse Strings B.ParityAlternatedDeletionsB.\ Parity\ Alt ...
- Codeforces Round #496 (Div. 3 ) E1. Median on Segments (Permutations Edition)(中位数计数)
E1. Median on Segments (Permutations Edition) time limit per test 3 seconds memory limit per test 25 ...
- Codeforces Round #797 (Div. 3) F. Shifting String题解
题意是给一个字符串s和一个与之相同长度的数组排列a,字符串s按照数组给定的位置进行变化,新字符串的第i个字符是上一个字符串的第a[i]个字符 比如 例子 5 ababa 2 1 4 5 3 变化6次 ...
- Codeforces Round #327 (Div. 2) C Median Smoothing(找规律)
分析: 三个01组合只有八种情况: 000 s 001 s 010 0 011 s 100 s 101 1 110 s 111 s 可以看出只有010,101是不稳定的.其他都是稳定的,且连续地出现了 ...
- Codeforces Round #550 (Div. 3) C.Two Shuffled Sequences
C. Two Shuffled Sequences Two integer sequences existed initially - one of them was strictly increas ...
- Codeforces Round #550 (Div. 3)C. Two Shuffled Sequences
Two integer sequences existed initially - one of them was strictly increasing, and the other one - s ...
- Codeforces Round #604 (Div.2)
Codeforces Round #604 (Div.2) 2019/12/5 22:35--2019/12/6 00:35 Codeforces Round #604 (Div.2) A. Beau ...
- Codeforces Round #617 (Div. 3) E2. String Coloring (hard version) 思维 + dp + Dilworth定理
传送门 文章目录 题意: 思路: 题意: 让你给一个串染色,不同颜色且相邻的一对字符可以互换位置,用最少的颜色,使交换后这个字符串字典序最小. 思路: 考虑将字符串分成若干个非递减的子序列,由于其非递 ...
最新文章
- Echo团队Alpha冲刺随笔 - 第九天
- 允许使用抽象类类型 isearchboxinfo 的对象_Java新手必学:面向对象的特性都有哪些?...
- 保存和加载pytorch模型
- Case when then esle end
- DiscuX END - 553 Envolope sender mismatch with header from..
- Easyx项目小合集
- linux 运行python 看不到异常信息_linux python运行报编码错误
- VPC2007差分硬盘让小硬盘也能跑多个虚拟机
- cf 1060e 树形dp 树上任意两点的距离和
- 第一次写CSDN的博客
- 联想服务器怎么使用无线网卡,Lenovo无线装置设置界面无法调节无线网卡
- Android逆向工程:MIUI系统大揭秘:去不掉的小米账号!
- 新建文件没有word、ppt、excel,office图标显示为白色,不能正常显示
- html添加空隙,html空隙
- 【干货收藏】统计分析/机器学习吐血整理最强指南
- 基于对抗互信息学习特征解耦的零样本语音转换|INTERSPEECH 2022
- 0基础如何学习自动化测试?按照这7步一步一步来学习就成功了
- OAuth2.0协议之新浪微博接口演示
- 浅析“一稿多投”的学术不端行为
- 验证https证书过期时间
热门文章
- XCODE 6.1.1 配置GLFW
- VC实用小知识总结 (一),转http://blog.csdn.net/myiszjf/article/details/10007431
- Notification和KVO有什么不同
- 时间不同单位之间的转换
- 从今天开始收集一些经典的算法。
- linux如何查看内存最大的几个文件,详解Linux如何查看当前占用CPU或内存最多的几个进程...
- Oracle11 expdp0734,oracle 11g expdp impdp 跨平台迁移数据
- android 动画x轴旋转,Android Roate3dAnimation实现围绕y轴竖直方向或者绕x轴方向旋转的3d动画效果...
- Halcon:(2)电路板检测实验
- 标准caffe中实现darknet相关层。caffe和darknet模型的相互转换和加速(分类、检测、分割)