您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: