B. War of the Corporations
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
Input
intellect
tell
Output
1
Input
google
apple
Output
0
Input
sirisiri
sir
Output
2
Note

In the first sample AI's name may be replaced with "int#llect".

In the second sample Gogol can just keep things as they are.

In the third sample one of the new possible names of AI may be "s#ris#ri".

题意: 求母串中有多少子串 (母串中字符只能使用一次)

比赛的时候傻了  本来可以上一波大分 小涨7分  水笔贴水题

贴q神代码  %%%

#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
const int MAXM=35;
char s[MAXN],t[MAXM];
int main()
{
scanf("%s%s",s,t);
int n=strlen(s),m=strlen(t);
int res=0;
for(int i=0;i+m<=n;i++)
{
bool flag=1;
for(int j=0;j<m;j++)
if(s[i+j]!=t[j])
flag=0;
if(flag)
{
s[i+m-1]='#';
res++;
}
}
printf("%d\n",res);
return 0;
}

  

Codeforces Round #342 (Div. 2) B的更多相关文章

  1. Codeforces Round #342 (Div. 2) D. Finals in arithmetic 贪心

    D. Finals in arithmetic 题目连接: http://www.codeforces.com/contest/625/problem/D Description Vitya is s ...

  2. Codeforces Round #342 (Div. 2) C. K-special Tables 构造

    C. K-special Tables 题目连接: http://www.codeforces.com/contest/625/problem/C Description People do many ...

  3. Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心

    B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long ...

  4. Codeforces Round #342 (Div. 2) A - Guest From the Past 数学

    A. Guest From the Past 题目连接: http://www.codeforces.com/contest/625/problem/A Description Kolya Geras ...

  5. Codeforces Round #342 (Div. 2) E. Frog Fights set 模拟

    E. Frog Fights 题目连接: http://www.codeforces.com/contest/625/problem/E Description stap Bender recentl ...

  6. Codeforces Round #342 (Div. 2) D. Finals in arithmetic(想法题/构造题)

    传送门 Description Vitya is studying in the third grade. During the last math lesson all the pupils wro ...

  7. Codeforces Round #342 (Div. 2) C. K-special Tables(想法题)

    传送门 Description People do many crazy things to stand out in a crowd. Some of them dance, some learn ...

  8. Codeforces Round #342 (Div. 2) B. War of the Corporations(贪心)

    传送门 Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Go ...

  9. Codeforces Round #342 (Div. 2) A. Guest From the Past(贪心)

    传送门 Description Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the detai ...

  10. Codeforces Round #342 (Div. 2)-B. War of the Corporations

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. 爬虫1.6-selenium+HeadlessChrome

    目录 爬虫-selenium+HeadlessChrome 1. 浏览器处理步骤 2. headless-chrome初体验 3. 实战爬取淘宝镇.街道信息 爬虫-selenium+HeadlessC ...

  2. java字符转义

    之前对java字符转义这一块稍作了解,在这里理理自己主观浅显的理解 这里会谈谈字符编码的是另一种问题和转义没有关系 以下面代码做分析 System.out.println("a". ...

  3. 腾讯云ubuntu安装使用MySQL

    安装步骤 ubuntu@VM---ubuntu:~$ sudo apt-get install mysql-server (密码: root/root) ubuntu@VM---ubuntu:~$ s ...

  4. 小程序开发中,纯css实现内容收起折叠功能

    不多说,直接上代码: wxml页面: <!--收起折叠 begin--> <view style='width:100%;background:#fff;border-top:1px ...

  5. smartgit 使用

    合并分支

  6. ELK部署方法

    最近经理开会说公司要安装ELK日志管理让我们搭建ELK,下面是我搭建步骤和流程,用三台机测试机器搭建的. 软件包我都 给你们放/usr/local/src/elk目录下安装目录都放在/usr/loca ...

  7. openstack多region介绍与实践---转

    概念介绍 所谓openstack多region,就是多套openstack共享一个keystone和horizon.每个区域一套openstack环境,可以分布在不同的地理位置,只要网络可达就行.个人 ...

  8. 1.安装hbase

    参考:http://hbase.apache.org/book.html#quickstart 一.下载hbase 去apache下载hbase,然后解压到/usr/local/hbase-1.1.3 ...

  9. BZOJ 4557 JLOI2016 侦查守卫 树形dp

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4557 题意概述: 给出一棵树,每个点付出代价w[i]可以控制距离和它不超过d的点,现在给 ...

  10. location 匹配规则 (NGINX)

    转:https://moonbingbing.gitbooks.io/openresty-best-practices/ngx/nginx_local_pcre.html location 匹配规则 ...