ACdream 1056 Vitaly and Strings
来源:互联网 发布:星光大道网络报名 编辑:程序博客网 时间:2024/05/20 05:22
一道水题,不过错了很多次,注意一下思维。
Description
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 stringss andt 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 andt.
Let's help Vitaly solve this easy problem!
Input
The first line contains strings (1 ≤ |s| ≤ 100), consisting of lowercase English letters. Here,|s| denotes the length of the string.
The second line contains stringt (|t| = |s|), consisting of lowercase English letters.
It is guaranteed that the lengths of stringss andt are the same and strings is lexicographically less than stringt.
Output
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.
Sample Input
ac
b
aaazzz
kkk
abcdefgabcdefh
No such string
#include <iostream>#include <cstring>#include <cstdio>using namespace std;char s1[110], s2[110];int main(){ int flag = 0; while(~scanf("%s%s", s1, s2)){ int len = strlen(s1); for(int i = len-1; i >= 0; --i){ if(s1[i] != 'z'){ s1[i]++; flag = 1; break; } else s1[i] = 'a'; } if(strcmp(s1, s2) >= 0 || flag == 0) printf("No such string\n"); else printf("%s\n", s1); } return 0;}
参考博客:http://www.cnblogs.com/I-love-HLD/p/4299364.html
- ACdream 1056 Vitaly and Strings
- Vitaly and Strings
- A. Vitaly and Strings
- A. Vitaly and Strings
- A. Vitaly and Strings
- Vitaly and Strings
- CF 518A(Vitaly and Strings-构造)
- codeforces 293 dvi2 A. Vitaly and Strings
- codeforces 518A Vitaly and Strings
- 518A - Vitaly and Strings【string】
- CF(#293 div2):A:Vitaly and Strings
- [CodeForces518A]Vitaly and Strings[字符串][构造]
- CF 293 A. Vitaly and Strings
- CodeForces 518A Vitaly and Strings
- Codeforces Round #293 (Div. 2)A. Vitaly and Strings
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings
- CodeForces - 518A Vitaly and Strings(水题)
- 【Code Forces】518A Vitaly and Strings(思维题)
- javascript表单的正则表达式
- 睡眠长短影响健康 多方面提高睡眠…
- Web API 实战之 统一的请求验证
- HTML5 LocalStorage 本地存储
- Loadrunner 9.5/11 java vuser环境配置问题(已解决)
- ACdream 1056 Vitaly and Strings
- 分享一篇GDB调试方法
- jeecg权限设计的介绍之数据权限
- org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError
- 子网掩码和ip地址的关系
- javascript call和apply方法详解
- MQTT协议初接触
- 关于UIMenuController的使用 弹出菜单UIMenuItem
- Saruman's Army(贪心)