Codeforces Round #293 (Div. 2) A. Vitaly and Strings
1 second
256 megabytes
standard input
standard output
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English letters, string s is lexicographically smaller than string t. Vitaly wondered if there is such string that is lexicographically larger than string s and at the same is lexicographically smaller than string t. This string should also consist of lowercase English letters and have the length equal to the lengths of strings s and t.
Let's help Vitaly solve this easy problem!
The first line contains string s (1 ≤ |s| ≤ 100), consisting of lowercase English letters. Here, |s| denotes the length of the string.
The second line contains string t (|t| = |s|), consisting of lowercase English letters.
It is guaranteed that the lengths of strings s and t are the same and string s is lexicographically less than string t.
If the string that meets the given requirements doesn't exist, print a single string "No such string" (without the quotes).
If such string exists, print it. If there are multiple valid strings, you may print any of them.
a
c
b
aaa
zzz
kkk
abcdefg
abcdefh
No such string
String s = s1s2... sn is said to be lexicographically smaller than t = t1t2... tn, if there exists such i, that s1 = t1, s2 = t2, ... si - 1 = ti - 1, si < ti.
题意:给你两个字符串a,b,然后让你输出一个字符串,这个字符串c要求满足 a<c<b
坑点在于z++之后,就不是字母了,这点需要判断一下就是了
string a;
string b;
string c;
int main()
{
cin>>a>>b;
c=a;
for(int i=a.size()-;i>=;i--)
{
if(c[i]=='z')
c[i]-=;
else
{
c[i]++;
break;
}
}
int flag=;
for(int i=;i<a.size();i++)
{
if(c[i]<b[i])
{
flag=;
break;
}
if(c[i]>b[i])
{
flag=;
break;
}
}
if(flag==)
cout<<"No such string"<<endl;
else
cout<<c<<endl;
}
Codeforces Round #293 (Div. 2) A. Vitaly and Strings的更多相关文章
- 水题 Codeforces Round #302 (Div. 2) A Set of Strings
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
- Codeforces Round #293 (Div. 2)
A. Vitaly and Strings 题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串 字符转处理:字典序排序 很巧妙的方法,因为s < t,只要找比t字典 ...
- Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 图论
D. Vitaly and Cycle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/p ...
- Codeforces Round #330 (Div. 2) A. Vitaly and Night 暴力
A. Vitaly and Night Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/p ...
- Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 奇环
题目链接: 点这里 题目 D. Vitaly and Cycle time limit per test1 second memory limit per test256 megabytes inpu ...
- Codeforces Round #311 (Div. 2) D - Vitaly and Cycle
D. Vitaly and Cycle time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #311 (Div. 2) D - Vitaly and Cycle(二分图染色应用)
http://www.cnblogs.com/wenruo/p/4959509.html 给一个图(不一定是连通图,无重边和自环),求练成一个长度为奇数的环最小需要加几条边,和加最少边的方案数. 很容 ...
- Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP
D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #293 (Div. 2) C. Anya and Smartphone 数学题
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- linux快速复制大量小文件方法 nc+tar【转】
1,在需要对大量小文件进行移动或复制时,用cp.mv都会显得很没有效率,可以用tar先压缩再解压缩的方式. 2,在网络环境中传输时,可以再结合nc命令,通过管道和tcp端口进行传输. nc和tar ...
- mysql优化【转】
最近听讲了博森瑞老师的mysql优化公开课,这个是我整理的笔记. 现在说一下mysql的内存和I/O方面的两个特点. 一. mysql内存特点: 1. 也有全局内存和每个session的内存(每个s ...
- Nagios Openstack Plugin
Some simple example for checking Openstack services check nova service list #!/bin/sh export OS_PROJ ...
- 【鬼脸原创】谷歌扩展--知乎V2.0
目的: 用键盘替代鼠标,做一个安静刷知乎的美男(女)子! 功能: 功能 按键 说明 直接定位到搜索框 q 打开 首页 w 打开 话题 e 打开 发现 r 打开 消息 m 打开 ...
- DOS命令基础,包涵DOS库说明书
20种常用的DOS命令小结 作者: 字体:[增加 减小] 类型:转载 DOS命令总共大约有一百个(包括文本编辑.查杀病毒.配置文件.批处理等),我们这里详细介绍二十个常用的DOS命令 先介 ...
- (转载)solr实现满足指定距离范围条件的搜索
配置schema.xml <?xml version="1.0" encoding="UTF-8" ?> <schema name=" ...
- vue 插槽slot
本文是对官网内容的整理 https://cn.vuejs.org/v2/guide/components.html#编译作用域 在使用组件时,我们常常要像这样组合它们: <app> < ...
- WINDOWS 2008 采用IP策略解决445,139等病毒攻击问题
@echo off title 创建IP安全策略,屏蔽135.. . . . 等端口 :: 配置说明文档地址 :: http://blog.csdn.net/lpc_china/article/det ...
- centos killall安装
https://blog.csdn.net/joeyon1985/article/details/46707865 https://blog.csdn.net/xupeng874395012/arti ...
- vim中E121:无法打开并写入文件解决办法
1.使用命令 :w !sudo tee % 保存即可. 其中: 冒号(:)表示我们处于vim的退出模式: 感叹号(!)表示我们正在运行shell命令: sudo和tee都是shell命令: %表示从 ...