求助!
  • 板块灌水区
  • 楼主LeoLiu_2011
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/7/19 09:19
  • 上次更新2023/11/3 08:58:47
查看原帖
求助!
755298
LeoLiu_2011楼主2023/7/19 09:19

RTRT

//50分代码
#include<bits/stdc++.h>
using namespace std;
int flag=1,l,l2,r,q;
string t,s;
int main(){
	cin>>s;
	cin>>q;
	while(q--){
		cin>>l2>>r;
		t=s.substr(l2-1,r-l2+1);
		l=t.size();
		flag=1;
		//cout<<t;
		for (int i=0;i<l;i++){
		    if (t[i]!='a'){
		        flag=0;
		        break;
		    }
		}
		if(flag){
		    cout<<"NULL"<<endl<<"Happy Chinese New Year!"<<endl;;
		    break;
		}
		for(int i=l-1;i>=0;i--){
		    if (t[i]=='a'){
		        t[i]='z';
		    }else{
		        t[i]-=1;
		        break;
		    }
		}
		cout<<t<<endl;
		if(s.find(t)!=-1){
		    cout<<"Happy New Year!"<<endl;
		}else{
		    cout<<"Happy Chinese New Year!"<<endl;
		}
	}
}
2023/7/19 09:19
加载中...