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 <cstring>
using namespace std; int main()
{
int T;
char a[];
char b[];
int i;
int j;
int count;
int temp;
int a_length;
int b_length; cin >> T;
while (T--)
{
cin >> a >> b; count = ;
a_length = strlen(a);
b_length = strlen(b);
for (i = ;i < b_length-a_length+;i++)
{
temp = i;
for (j = ;j < a_length;temp++,j++)
{
if (b[temp] != a[j])
{
break;
}
} if (j >= a_length)
{
count++;
}
}
cout << count << endl;
}
return ;
}

NYOJ5 Binary String Matching的更多相关文章

  1. NYOJ5——Binary String Matching

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

  2. Binary String Matching

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

  3. NYOJ之Binary String Matching

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

  4. ACM Binary String Matching

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

  5. Binary String Matching(kmp+str)

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

  6. NYOJ 5 Binary String Matching

    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. nyoj 题目5 Binary String Matching

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

  9. nyoj 5 Binary String Matching(string)

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

随机推荐

  1. Linux上安装wine qq的方法

    linxu上安装QQ的发 百度网盘 提取码:f2sn 步骤一.安装wine(详见:https://www.winehq.org/download) // ubuntu/ubuntukylin/mint ...

  2. 列表框、分组列表框、标签(label)、分组框(fieldset)、框架(frameset)

    列表框(select) 下拉列表,用户可以从一些可选项中选择. 示例:简单的下拉列表 <select name="country"> <option value= ...

  3. mysql之命令行导入导出

    命令介绍 mysqldump:导出命令,在系统”命令提示符“窗口直接使用,如果提示没有此命令(前提是已经安装成功mysql),在环境变量中的path添加mysql,即path=D:\xxx\mysql ...

  4. 树莓派连接arduino(USB串口通讯)

    2018-06-0115:12:19 https://blog.csdn.net/song527730241/article/details/50884890 重要步骤  查看端口:(ttyUSB0或 ...

  5. C++(extern关键字的理解和作用深入)

    extern关键字的理解和作用深入 extern是一个关键字,它告诉编译器存在着一个变量或者一个函数,如果在当前编译语句的前面中没有找到相应的变量或者函数, 也会在当前文件的后面或者其它文件中定义 引 ...

  6. PHP开发心得四

    1,php返回给html页面的Json数据不能含有回车符 某次用php编写查询数据库数据,以json格式返回给前端页面js文件,js文件以angularJS的函数调用处理的方式进行数据显示,但数据返回 ...

  7. Verilog之event

    1 Explicit event The value changes on nets and variable can be used as events to trigger the executi ...

  8. JAVA 学习笔记 - 基础语法 2

    ---恢复内容开始--- 1.数组的申明和应用 数据类型 数组名称[] = null;             //在堆栈中申明变量名称 数组名称 =  new  数据类型[10];       // ...

  9. JMeter在linux上分布式压测遇到的坑(三)

    master和slave机要在同一网段内,才能做分布式(Jmeter要配环境变量,这样不用手动起server) 分布式不成功,解决方案: 1.master端和slave端要ping通 2.ping通后 ...

  10. R语言学习 - 线图绘制

    线图是反映趋势变化的一种方式,其输入数据一般也是一个矩阵. 单线图 假设有这么一个矩阵,第一列为转录起始位点及其上下游5 kb的区域,第二列为H3K27ac修饰在这些区域的丰度,想绘制一张线图展示. ...