首页 > 其他 > 详细

HDU2087 剪花布条

时间:2017-12-20 19:46:53      阅读:196      评论:0      收藏:0      [点我收藏+]

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2087

这道题看大佬们都用KMP做,但本萌新用string弱弱水过。。。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <stdlib.h>
 5 #include <algorithm>
 6 #include <math.h>
 7 #include <vector>
 8 #include <list>
 9 #include <map>
10 #include <set>
11 using namespace std;
12 
13 int main()
14 {
15     string str1;
16     while(cin>>str1)
17     {
18         if(str1[0]==#) break;
19         string str2;
20         int sum=0;
21         cin>>str2;
22         for(;str1.find(str2)!=string::npos;)
23         {
24             int key=str1.find(str2);
25             sum++;
26             for(int a=key;a<key+str2.size();a++)
27             {
28                 str1.erase(str1.begin()+key);
29             }
30         }
31         cout<<sum<<endl;
32     }
33 }

 

HDU2087 剪花布条

原文:http://www.cnblogs.com/Culion-BEAR/p/8075248.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!