首页 > 其他 > 详细

Codeforces - 625B 贪心

时间:2017-12-09 15:22:09      阅读:190      评论:0      收藏:0      [点我收藏+]

求最小不重复匹配次数
改最后一个字符最划算
我当时怎么就没看出来..

#include<bits/stdc++.h>
using namespace std;
string S,T;
int main(){
    while(cin>>S>>T){
        int ans=0;
        for(int i = 0; i < S.length();){
            if(T==S.substr(i,T.length())){
                ans++; 
                S[i+T.length()-1]=‘#‘;
                i=i+T.length();
            }
            else i++;
//          cout<<S<<endl;
        }
        cout<<ans<<endl;
    }
}

Codeforces - 625B 贪心

原文:http://www.cnblogs.com/caturra/p/8011551.html

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