time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard 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”.

在原字符中至少增添多少个#使得没有第二个字符串,暴力即可

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int>PII; typedef vector<int>VI; typedef vector<LL>VL; const int INF = 0x3f3f3f3f; const double eps = 1e-6; const double Pi = acos(-1.0); char str[100100]; char c[40]; int main()
{
scanf("%s %s",str,c); int len = strlen(str); int ans = 0; for(int i=0;i<len;i++)
{
if(str[i]==c[0])
{
int k;
for( k=0;c[k]!='\0';k++)
{
if(str[i+k]!=c[k])
{
break;
}
} if(c[k]=='\0')
{
ans++; i=i+k-1;
}
}
} printf("%d\n",ans);
return 0;
}

Codeforces Round #342 (Div. 2)-B. War of the Corporations的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #342 (Div. 2)

    贪心 A - Guest From the Past 先买塑料和先买玻璃两者取最大值 #include <bits/stdc++.h> typedef long long ll; int ...

  4. Codeforces Round #342 (Div. 2) B

    B. War of the Corporations time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

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

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

  9. 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 ...

随机推荐

  1. tp文件上传;org/RBAC.class.php 权限类;think/page,class,php分页类;

    一.上传表单: 注意,要使用上传功能 你的表单需要设置 enctype="multipart/form-data" <form action="__URL__/up ...

  2. android内存分析:heap Snapshot的使用

    网上有很多讲解关于android studio中memory工具的使用,接下来我来说一段在项目中发生的实例:大家可以根据我的这个方法来分析自己项目中的问题 首先我们要通过手动先触发GC操作,点击mem ...

  3. KnocKout 绑定数据

    Controller 里面的方法: public ActionResult Index() { return View(); } [HttpPost] public JsonResult Reader ...

  4. Spring Data JPA

    转自: http://www.cnblogs.com/WangJinYang/p/4257383.html Spring 框架对 JPA 的支持 Spring 框架对 JPA 提供的支持主要体现在如下 ...

  5. LeetCode First Unique Character in a String

    原题链接在这里:https://leetcode.com/problems/first-unique-character-in-a-string/ 题目: Given a string, find t ...

  6. alert()、confirm()和prompt()的区别与用法

    1.警告消息框alertalert 方法有一个参数,即希望对用户显示的文本字符串.该字符串不是 HTML 格式.该消息框提供了一个"确定"按钮让用户关闭该消息框,并且该消息框是模式 ...

  7. C#通过SSH连接MySql

    出于安全考虑,有的时候数据库服务器只能通过SSH访问,比如MySql服务装在了服务器A上,并且A机器只允许B机器才能访问,而部署环境可能在C机器上,这时候就要C服务器通过B服务器连接A服务器,这时候就 ...

  8. Unity Mono IDE Setting

    Mac: 修改快捷键 删除一整行 Delete Entire Line    Command+D Format Document   Shift+Command+F 在文件中查找 Fin in Fil ...

  9. UML基本介绍

    用例图: 概念:描述用户需求,从用户的角度描述系统的功能,是用户拨通观察到的系统功能的模型图,用例是系统中的一个功能单元. 实现:椭圆表示某个用例:人形符号表示角色. 目的:帮助开发团队以一种可视化的 ...

  10. EL表达式查询出来的数据,下载成excel表格,很实用的

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...