洛谷链接 牛客链接
两个平台都过了
题目:
题解:
本题是一道比较硬核的模拟题,思路方面其实问题不大,但是难在模拟情况上面
而且测试数据里还包含了一些题目中没有提到的情况,所以需要多加一些判断,比如 d-4
这种情况不需要展开
#include "bits/stdc++.h"
using namespace std;
int main(){
int p1,p2,p3;
char x;
cin>>p1>>p2>>p3;
string str;
cin>>str;
if(p1==1){
if(p3==1){
for(int i=0;i<str.size();i++){
if(((isalpha(str[i])&&str[i+1]=='-'&& isalpha(str[i+2]))||(isdigit(str[i])&&str[i+1]=='-'&& isdigit(str[i+2])))&&str[i]<str[i+2]){
cout<<str[i];
x=str[i]+1;
for(int j=0;j<str[i+2]-str[i]-1;j++){
for(int k=0;k<p2;k++)cout<<x;
x++;
}
i++;
}
else cout<<str[i];
}
}
else {
for(int i=0;i<str.size();i++){
if(((isalpha(str[i])&&str[i+1]=='-'&& isalpha(str[i+2]))||(isdigit(str[i])&&str[i+1]=='-'&& isdigit(str[i+2])))&&str[i]<str[i+2]){
cout<<str[i];
x=str[i+2]-1;
for(int j=0;j<str[i+2]-str[i]-1;j++){
for(int k=0;k<p2;k++)cout<<x;
x--;
}
i++;
}
else cout<<str[i];
}
}
}
else if(p1==2){
if(p3==1){
for(int i=0;i<str.size();i++){
if(((isalpha(str[i])&&str[i+1]=='-'&& isalpha(str[i+2]))||(isdigit(str[i])&&str[i+1]=='-'&& isdigit(str[i+2])))&&str[i]<str[i+2]){
cout<<str[i];
x=str[i]+1;
for(int j=0;j<str[i+2]-str[i]-1;j++){
for(int k=0;k<p2;k++)cout<<(char)::toupper(x);
x++;
}
i++;
}
else cout<<str[i];
}
}
else {
for(int i=0;i<str.size();i++){
if(((isalpha(str[i])&&str[i+1]=='-'&& isalpha(str[i+2]))||(isdigit(str[i])&&str[i+1]=='-'&& isdigit(str[i+2])))&&str[i]<str[i+2]){
cout<<str[i];
x=str[i+2]-1;
for(int j=0;j<str[i+2]-str[i]-1;j++){
for(int k=0;k<p2;k++)cout<<(char)::toupper(x);
x--;
}
i++;
}
else cout<<str[i];
}
}
}
else if(p1==3){
for(int i=0;i<str.size();i++){
if(((isalpha(str[i])&&str[i+1]=='-'&& isalpha(str[i+2]))||(isdigit(str[i])&&str[i+1]=='-'&& isdigit(str[i+2])))&&str[i]<str[i+2]){
cout<<str[i];
for(int j=0;j<str[i+2]-str[i]-1;j++){
for(int k=0;k<p2;k++)cout<<'*';
}
i++;
}
else cout<<str[i];
}
}
}
标签:p3,NOIP2007,洛谷,int,p1,P1098
From: https://www.cnblogs.com/ChengMao/p/17058192.html