Processing math: 100%

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\n",s);

    return 0;
}
复制代码

 

posted @   Fighting_Heart  阅读(132)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
阅读排行:
· C# 13 中的新增功能实操
· Ollama本地部署大模型总结
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(4)
· langchain0.3教程:从0到1打造一个智能聊天机器人
· 2025成都.NET开发者Connect圆满结束
历史上的今天:
2015-09-02 ZOJ 2866 Overstaffed Company
2015-09-02 POJ 3307 Smart Sister
2015-09-02 ZOJ 2872 Binary Partitions
点击右上角即可分享
微信分享提示