您的位置:首页 > 其它

CodeForces A. Letters Cyclic Shift【字符串】

2016-09-06 11:22 176 查看
A. Letters Cyclic Shift

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly
one non-empty substring of s and shift all its letters 'z' 

 'y' 

 'x' 

 'b' 

 'a' 

 'z'.
In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.

What is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?

Input

The only line of the input contains the string s (1 ≤ |s| ≤ 100 000)
consisting of lowercase English letters.

Output

Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.

Examples

input
codeforces


output
bncdenqbdr


input
abacaba


output
aaacaba


Note

String s is lexicographically smaller than some other string t of
the same length if there exists some 1 ≤ i ≤ |s|, such thats1 = t1, s2 = t2, ..., si - 1 = ti - 1,
and si < ti.
刚做这首题的时候,宝宝也是很无语,一堆英文看不懂也就算了。。给的数据也让我分析不出来。。最后好不容易搞懂了,用JAVA写了一遍,超时,用C写,超时,最后用C++才给过了。。百度的时候发现了一个神奇的头文件#include<bits/stdc++.h>,据说包含了C++里的所有头文件,长姿势了,,,
code:
#include<bits/stdc++.h>
using namespace std;
int main() {
string str;
int i,j;
cin>>str;
for(i=0;i<str.size();i++){
if(str[i]!='a'){
break;
}
}
for(j=i;j<str.size();j++){
if(str[j]=='a'){
break;
}
str[j]--;
}
if(i==str.size()){
str[str.size()-1]='z';
}
cout<<str<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: