博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心
阅读量:7127 次
发布时间:2019-06-28

本文共 2239 字,大约阅读时间需要 7 分钟。

B. War of the Corporations

题目连接:

Description

A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.

This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineapple did their best to postpone the release of Lastus 3000 as long as possible. Finally, they found out, that the name of the new artificial intelligence is similar to the name of the phone, that Pineapple released 200 years ago. As all rights on its name belong to Pineapple, they stand on changing the name of Gogol's artificial intelligence.

Pineapple insists, that the name of their phone occurs in the name of AI as a substring. Because the name of technology was already printed on all devices, the Gogol's director decided to replace some characters in AI name with "#". As this operation is pretty expensive, you should find the minimum number of characters to replace with "#", such that the name of AI doesn't contain the name of the phone as a substring.

Substring is a continuous subsequence of a string.

Input

The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.

Output

Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.

Sample Input

intellect

tell

Sample Output

1

Hint

题意

给你s1 s2,你每次操作可以使得s1串中某个字符变成#,然后问你最小修改多少次,就可以使得s1中不含有s2子串

题解:

贪心,我们每次修改最后一个字符就好了

这样相交的一定都被修改了

代码

#include
using namespace std;string s1,s2;int main(){ cin>>s1>>s2; int ans = 0; for(int i=0;i
s1.size()) { flag = 1; break; } if(s1[i+j]!=s2[j]) { flag = 1; break; } } if(flag==0) { s1[i+s2.size()-1]='#'; ans++; } } cout<
<

转载地址:http://cahel.baihongyu.com/

你可能感兴趣的文章
myeclips快捷键和自动提示设置
查看>>
《GettingThingsDone》--GTD学习笔记(三)-GTD的三个关键原则
查看>>
libvirt(virsh命令总结)
查看>>
OD调试6—使未注册版软件的功能得以实现
查看>>
I.MX6 查找占用UART进程
查看>>
Ubuntu 搭建 LAMP 服务器
查看>>
The Elements of Programming Style
查看>>
简述一下src与href的区别
查看>>
跨域请求被拒绝的问题
查看>>
第六天
查看>>
POJ 1256:Anagram
查看>>
cocos2dx 云彩特效
查看>>
poj3140(树的dfs)
查看>>
Castle ActiveRecord的一对多问题
查看>>
VM安装系统时提示硬件不支持(unsupported hardware detected)
查看>>
mmap探究
查看>>
那些常用的eclipse快捷键
查看>>
C++中处理XML文件
查看>>
团队编程项目作业1-成员简介及分工
查看>>
LuoguP1126 机器人搬重物(BFS)
查看>>