Binary String Matching

描述

Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 3, because the pattern A appeared at the posit

输入
The first line consist only one integer N, indicates N cases follows. In each case, there are two lines, the first line gives the string A, length (A) <= 10, and the second line gives the string B, length (B) <= 1000. And it is guaranteed that B is always longer than A.
输出
For each case, output a single line consist a single integer, tells how many times do B appears as a substring of A.
样例输入
3
11
1001110110
101
110010010010001
1010
110100010101011 
样例输出
3
0
3 
#include <iostream>
#include <string>using namespace std;int main()
{int n;cin>>n;while(n--){string strA;string strB;int count = 0;cin>>strA;cin>>strB;int A = strA.size();int B = strB.size();for(int i=0; i<B; i++){if(strB.substr(i, A) == strA)count ++;}cout<<count<<endl;}return 0;
}        

Binary String Matching相关推荐

  1. nyoj 题目5 Binary String Matching

    Binary String Matching 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alpha ...

  2. NYOJ Binary String Matching的stl解法 酒馆浪人的博客

    Binary String Matching 时间限制: 3000 ms  |  内存限制: 65535 KB 难度: 3 描述 Given two strings A and B, whose al ...

  3. Binary String Matching(C++)

    题目描述: Given two strings A and B, whose alphabet consist only '0' and '1'. Your task is only to tell ...

  4. 南阳5--Binary String Matching(Kmp)

    Binary String Matching 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alpha ...

  5. Binary String Reconstruction CodeForces - 1352F(思维+构造)

    For some binary string s (i.e. each character si is either '0' or '1'), all pairs of consecutive (ad ...

  6. Binary String Minimizing CodeForces - 1256D(贪心)

    You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). I ...

  7. 【2019牛客暑期多校训练营(第三场)- B】Crazy Binary String(思维,01串,前缀和)

    题干: 链接:https://ac.nowcoder.com/acm/contest/883/B 来源:牛客网 ZYB loves binary strings (strings that only ...

  8. string matching(HDU-6629)

    Problem Description String matching is a common type of problem in computer science. One string matc ...

  9. Binary String Constructing(CF-1003B)

    Problem Description You are given three integers aa, bb and xx. Your task is to construct a binary s ...

最新文章

  1. 引入外部css_css
  2. oracle绑定变量赋值,Oracle教程之绑定变量
  3. 与nlp相关的模型概览
  4. 程序片上(内)执行-nandFlash-norFlash
  5. 跳转到企业缓存之前要考虑的事项
  6. php操作带中文的json数据
  7. 怎么修改RO服务器版本,谁知道build.prop的系统版本号怎么改
  8. 数论 —— 佩尔方程与连分数
  9. Linux终端登QQ,Linux下登录腾讯QQ的方法
  10. 菜鸟教程:零基础HTML入门
  11. 使用Photoshop制作名片
  12. MYSQL 多表创建视图
  13. Wise Force Deleter(电脑文件强制删除软件)官方中文版V1.5.3.54 | 支持强制删除超大文件夹
  14. Projector 远程访问 pycharm IDE
  15. June 12th No Matter How
  16. 解决 windows 下浏览器无法上网,QQ/微信正常上网
  17. 空气质量指数(AQI)分析与预测
  18. 关于拉流端ts时间切片问题导致的直播黑屏问题
  19. 在html页面中怎么打印区域,网页打印代码,可以打印指定区域的
  20. 机械革命 Code Go 评测

热门文章

  1. 蛮力法在求解最优解问题中的应用(JAVA)--旅行家问题、背包问题、分配问题
  2. python的编程模式有哪两种_python程序的两种运行方式是什么
  3. 长方形与圆最近连线LISP_餐桌到底选方还是圆?可千万别买错了,今天我们好好聊聊...
  4. MYSQL描述选课系统的问题与_mysql+php实现选课系统中遇到的问题及解决方法
  5. 文件上传控件 css,CSS3 自定义文件上传输入控件界面
  6. linux火狐自动更新,CentOS 7手动更新firefox | Linux系统运维联盟
  7. JAVA语言运算符(算数运算符、赋值运算符、比较运算符、逻辑运算符、三元运算)
  8. bootstrap中分页、面包屑导航、列表组、卡片、下拉菜单、折叠
  9. C++ 空指针和野指针
  10. 机器学习笔记(七)——决策树模型