fzu校赛B题

题目链接:http://acm.fzu.edu.cn/contest/problem.php?cid=129&sortid=2

思路:一开始思路有点混乱,然后仔细一看数据,发现暴力即可。

View Code
 1 #include<iostream>

 2 #include<cstdio>

 3 #include<cstring>

 4 #include<string>

 5 using namespace std;

 6 const int MAXN=50005;

 7 char s3[MAXN];

 8 int num[MAXN];

 9 

10 int main(){

11     char s1[110],s2[110];

12     while(gets(s1)){

13         int len=strlen(s1),k=0;

14         for(int i=0;i<len;i++){

15             if(s1[i]>='A'&&s1[i]<='Z')s1[i]=s1[i]-'A'+'a';

16         }

17         

18         gets(s2);

19         gets(s3);

20         string s(s1),ss(s2),sss(s3);

21         string result;

22         for(int i=0;i<sss.size();i++){

23             string str;

24             for(int j=0;j<s.size();j++)if(i+j<sss.size()){

25                 if(sss[i+j]>='A'&&sss[i+j]<='Z'){

26                     str+=sss[i+j]-'A'+'a';

27                 }else 

28                     str+=sss[i+j];

29             }

30             if(str==s){i+=s.size()-1;result+=ss;}

31             else result+=sss[i];

32         }

33         cout<<result<<endl;

34     }

35     return 0;

36 }

 

你可能感兴趣的:(B)