求最小不重复匹配次数

改最后一个字符最划算

我当时怎么就没看出来..

#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 贪心的更多相关文章

  1. CodeForces - 893D 贪心

    http://codeforces.com/problemset/problem/893/D 题意 Recenlty Luba有一张信用卡可用,一开始金额为0,每天早上可以去充任意数量的钱.到了晚上, ...

  2. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  3. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 828D) - 贪心

    Arkady needs your help again! This time he decided to build his own high-speed Internet exchange poi ...

  4. CodeForces - 93B(贪心+vector<pair<int,double> >+double 的精度操作

    题目链接:http://codeforces.com/problemset/problem/93/B B. End of Exams time limit per test 1 second memo ...

  5. 【38.02%】【codeforces 625B】War of the Corporations

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  6. C - Ordering Pizza CodeForces - 867C 贪心 经典

    C - Ordering Pizza CodeForces - 867C C - Ordering Pizza 这个是最难的,一个贪心,很经典,但是我不会,早训结束看了题解才知道怎么贪心的. 这个是先 ...

  7. Codeforces 570C 贪心

    题目:http://codeforces.com/contest/570/problem/C 题意:给你一个字符串,由‘.’和小写字母组成.把两个相邻的‘.’替换成一个‘.’,算一次变换.现在给你一些 ...

  8. Codeforces 732e [贪心][stl乱搞]

    /* 不要低头,不要放弃,不要气馁,不要慌张 题意: 给n个插座,m个电脑.每个插座都有一个电压,每个电脑都有需求电压. 每个插座可以接若干变压器,每个变压器可以使得电压变为x/2上取整. 有无限个变 ...

  9. Codeforces 721D [贪心]

    /* 不要低头,不要放弃,不要气馁,不要慌张. 题意: 给一列数a,可以进行k次操作,每次操作可以选取任意一个数加x或者减x,x是固定的数.求如何才能使得这个数列所有数乘积最小. 思路: 贪心...讨 ...

随机推荐

  1. Hadoop YARN: 1/1 local-dirs are bad: /var/lib/hadoop-yarn/cache/yarn/nm-local-dir; 1/1 log-dirs are bad: /var/log/hadoop-yarn/containers hdfs硬盘90% yarn unhealthy

    1/1 local-dirs are bad: /var/lib/hadoop-yarn/cache/yarn/nm-local-dir; 1/1 log-dirs are bad: /var/log ...

  2. hadoop再次集群搭建(5)-CDH Install

       登录 http://node1.com:7180/.用户名和密码都是admin.启动服务命令是 service  cloudera-scm-server start 最开始两个页面直接conti ...

  3. NoSQL概述

  4. new与delete,malloc与free

    1.new_delete与malloc_free ❶malloc/free: malloc原型: void *malloc(long NumBytes) 该函数分配了NumBytes个字节,并返回了指 ...

  5. HTTP、TCP、UDP、Socket关系详解

    TCP.UDP和HTTP关系是什么? 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议.在传输层中有TCP ...

  6. HDU 4879 ZCC loves march (并查集,set,map)

    题面以及思路:https://blog.csdn.net/glqac/article/details/38402101 代码: #include <bits/stdc++.h> #defi ...

  7. boost::fucntion 用法详解

    转载自:http://blog.csdn.net/benny5609/article/details/2324474 要开始使用 Boost.Function, 就要包含头文件 "boost ...

  8. #pragma pack()用法详解

    博客转载自:http://blog.csdn.net/lime1991/article/details/44536343 1.什么是对齐?为什么要对齐? 现代计算机中内存空间都是按照byte划分的,从 ...

  9. Ubuntu 添加用户到sudoers

    ubuntu上的用户有时候需要用到管理员权限,可以通过修改 /etc/sudoers 文件内容添加用户权限. 操作方式 1. 首先以root进入系统打开文件 sudo vim /etc/sudoers ...

  10. vray学习笔记(5)-学习资料

    首先肯定是vray的官方的资料了: 一个是教程 https://docs.chaosgroup.com/display/VRAY3MAX/Tutorials 一个是帮助文件 https://docs. ...