Codeforces Round #293 (Div. 2) A. Vitaly and Strings
2015-03-25 20:01
381 查看
题目地址:http://codeforces.com/contest/518/problem/A
/* 题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串 字符转处理:字典序排序 很巧妙的方法,因为s < t,只要找比t字典序稍微小一点的和s比较就行了 具体方法和数字减1相类似,从"个位"减1,如果是0,从前面借1 !strcmp (t, s):如果t < s 或者 t > s (不可能)则输出,t == s 则输出NO */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <set> using namespace std; const int MAXN = 1e6 + 10; const int INF = 0x3f3f3f3f; int main(void) { //freopen ("A.in", "r", stdin); char s[110], t[110]; while (~scanf ("%s %s", &s, &t)) { int cnt = strlen (s) - 1; while (t[cnt] == 'a' && cnt >= 0) { t[cnt] = 'z'; cnt--; } t[cnt]--; (!strcmp (t, s)) ? puts ("No such string") : printf ("%s\n", t); } return 0; }
相关文章推荐
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings
- Codeforces Round #293 (Div. 2)--A-- Vitaly and Strings - Painting
- 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(思路)
- Codeforces Round #293 (Div. 2) A. Vitaly and Strings
- Codeforces Round #293 (Div. 2)——A—— Vitaly and Strings
- CF(#293 div2):A:Vitaly and Strings
- Vitaly and Strings
- CF Vitaly and Strings
- Codeforces #410(div2) B. Mike and strings (暴力枚举
- Codeforces Round #226 (Div. 2) B. Bear and Strings
- CF 226 DIV2 B. Bear and Strings
- Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 图论
- Codeforces Round #358 (Div. 2) Alyona and Strings
- Codeforces Round #358 (Div. 2) D. Alyona and Strings
- Codeforces Round #311 (Div. 2) D - Vitaly and Cycle(二分图染色应用)
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp
- [CodeForces518A]Vitaly and Strings[字符串][构造]
- Codeforces Round #358 (Div. 2) D. Alyona and Strings dp