zoukankan      html  css  js  c++  java
  • CodeForces 709C Letters Cyclic Shift

    贪心。

    肯定是两个$a$之间的那些字符都$-1$,没有$a$就全部$-1$。如果输入的串全是$a$,那么把最后一个$a$改成$z$。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-6;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
    }
    
    const int maxn=100010;
    char s[maxn]; bool flag;
    
    int main()
    {
        scanf("%s",s);
        for(int i=0;s[i];i++)
        {
            if(s[i]=='a')
            {
                if(flag==0) continue;
                else break;
            }
            s[i]--; flag=1;
        }
    
        if(flag==0)
        {
            int len=strlen(s);
            s[len-1]='z';
        }
        printf("%s
    ",s);
    
        return 0;
    }
  • 相关阅读:
    mysql总结
    git总结
    转:如何判断一家公司的好坏
    路越走越窄,尤其做技术的
    百度面试总结
    背叛
    which和whereis 命令
    bzoj3263 陌上花开 CDQ模板
    bzoj 2653middle
    暑假第十九测
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5835693.html
Copyright © 2011-2022 走看看