518A - Vitaly and Strings【string】
来源:互联网 发布:知乎怎么保存图片 编辑:程序博客网 时间:2024/05/08 07:51
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, strings is lexicographically smaller than stringt. Vitaly wondered if there is such string that is lexicographically larger than strings and at the same is lexicographically smaller than stringt. This string should also consist of lowercase English letters and have the length equal to the lengths of stringss 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 andt 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.
ac
b
aaazzz
kkk
abcdefgabcdefh
No such string
String s = s1s2...sn is said to be lexicographically smaller thant = t1t2...tn, if there exists such i, that s1 = t1, s2 = t2, ...si - 1 = ti - 1, si < ti.
小的字符串加一,如果小于等于大的字符串,输出这个字符串
int main(){ string a,b; cin>>a>>b; for(int i=a.length()-1;i>=0;i--) { if(a[i]=='z')a[i]='a'; else { a[i]++; break; } } a<b?cout<<a<<endl:cout<<"No Such String"<<endl; return 0;}
- 518A - Vitaly and Strings【string】
- A. Vitaly and Strings
- A. Vitaly and Strings
- A. Vitaly and Strings
- CF 518A(Vitaly and Strings-构造)
- codeforces 518A Vitaly and Strings
- CodeForces 518A Vitaly and Strings
- CodeForces - 518A Vitaly and Strings(水题)
- 【Code Forces】518A Vitaly and Strings(思维题)
- codeforces 293 dvi2 A. Vitaly and Strings
- CF(#293 div2):A:Vitaly and Strings
- CF 293 A. Vitaly and Strings
- Vitaly and Strings
- Vitaly and Strings
- Codeforces Round #293 (Div. 2)A. Vitaly and Strings
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings
- Codeforces Round #293 (Div. 2)--A-- Vitaly and Strings - Painting
- ACdream 1056 Vitaly and Strings
- 贪心算法解硬币找零问题
- Java代码生成利器之rapid-generate应用一
- 自考《运筹学》之第9~11章
- IOS 音频播放器
- 《Linux/UNIX系统编程手册》 英文版读书笔记syslog学习记录
- 518A - Vitaly and Strings【string】
- 寒假总结
- 给Spring的placeholder设置默认值
- 手机访问同局域网内运行的tomcat
- Accelerated C++学习笔记chapter one
- neu 1518 New Hanoi Tower(矩阵,递推)
- 素数筛选法
- iOS开发之-KVC的实现原理探讨
- 【C语言探索之旅】 第二部分第三课:数组