Binary String Matching

时间限制:3000 ms  |  内存限制:65535 KB
难度:3
 
描述
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()
{
string a,b;
int n;cin>>n;
while(n--)
{
cin>>a>>b;
int count=;
unsigned int num=b.find(a,);
while(num!=string::npos)
{
count++;
num=b.find(a,num+);
}
cout<<count<<endl;
}
}

NYOJ 5 Binary String Matching的更多相关文章

  1. NYOJ之Binary String Matching

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

  2. nyoj 5 Binary String Matching(string)

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

  3. nyoj 题目5 Binary String Matching

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

  4. Binary String Matching

    问题 B: Binary String Matching 时间限制: 3 Sec  内存限制: 128 MB提交: 4  解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...

  5. ACM Binary String Matching

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

  6. Binary String Matching(kmp+str)

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

  7. 【ACM】Binary String Matching

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

  8. NYOJ5——Binary String Matching

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

  9. NYOJ5 Binary String Matching

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

随机推荐

  1. php后台数组foreach嵌套循环

    <?php foreach($list as $key=>$val){ ?> <tr class="over_odd"> <td align=& ...

  2. cssradius

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  3. java连接mysql源码

    import java.sql.; import java.text.SimpleDateFormat; import java.util.; import java.util.Date; impor ...

  4. 邪恶改装2:用单片机实现一次简单的wifi密码欺骗

    0×00 前言 前段时间用TPYBoard v202 做了一个简单的WIFI干扰攻击器(ps :没有看过的小伙伴,可以看一下:http://www.freebuf.com/column/136985. ...

  5. 取得system32文件夹下面文件的写入权限

    取得system32文件夹下面文件的写入权限 TAKEOWN /F %SystemRoot%\system32\riched32.dll ICACLS %SystemRoot%\system32\ri ...

  6. 如何查看安装的sql server是什么版本

    方法 1:通过使用 SQL Server Management Studio 中的对象资源管理器连接到服务器.连接对象资源管理器后,它将显示版本信息(在括号中),以及用于连接到 SQL Server ...

  7. IE浏览器兼容问题(上)——html和css的兼容写法

    用户使用的浏览器五花八门,我们要保证每一种浏览器都能兼容我们的代码,不能要求用户去改变浏览器,那么就得在我们的代码上下功夫.此时我们要用到hack. HACK就是针对不同的浏览器写不同的HTML.CS ...

  8. 剖析touch事件在View中的传递

    话不多说,直奔主题,先来看一张图 版权申明:这是csdn上别人的图,我觉得有用,就拿过来了, 然后简单说明下: 总的来说,触摸事件是从最外层的ViewGroup,一级一级传递进来的 和这相关的每个Vi ...

  9. MySQL触发器更新和插入操作

    一.触发器概念 触发器(trigger):监视某种情况,并触发某种操作,它是提供给程序员和数据分析员来保证数据完整性的一种方法,它是与表事件相关的特殊的存储过程,它的执行不是由程序调用,也不是手工启动 ...

  10. 列表操作之定义,切片(取元素)(Python)

    学完列表,元组,字典,集合以后,发现他们长的有些像,傻傻分不清,现在回顾下,以代码为例进行分析每一种操作的属性.(英语不佳,错误请忽略) 举栗如下:names = ["hbb",' ...