NYOJ 5 Binary String Matching
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()
{
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的更多相关文章
- NYOJ之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
- nyoj 5 Binary String Matching(string)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- nyoj 题目5 Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- Binary String Matching
问题 B: Binary String Matching 时间限制: 3 Sec 内存限制: 128 MB提交: 4 解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...
- ACM Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- Binary String Matching(kmp+str)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- 【ACM】Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- NYOJ5——Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述:Given two strings A and B, whose alph ...
- NYOJ5 Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
随机推荐
- Centos使用vsfotd配置fpt服务
---恢复内容开始--- vsftp简介 vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux, BSD, Solaris, HP-UX 以及 IRIX 上面. ...
- 遇到的Mysql的一个坑
自己写的Java代码怎么也无法操作MySQL的写操作,打印SQL语句没有问题,检查连接也没有问题,最后手动写了一条记录,发现主键重复了,但是当时表是空的!所以就很震惊,于是选择删表重新来一次,这回成功 ...
- oauth简单使用
一.oauth原理参考 理解OAuth 2.0 二.本例中采用授权码模式 大致流程 (A)用户访问客户端,后者将前者导向认证服务器. (B)用户选择是否给予客户端授权. (C)假设用户给予授权,认证服 ...
- Configure: error: freetype.h not found. 的解决办法
出现 Configure: error: freetype.h not found. 的解决办法 CentOS yum install freetype-devel Debian apt-get in ...
- Python3中文件处理
1.txt,xls,doc等文件的使用 f=open("filename","w") 打开一个用于写入的文件,要写入内容时使用f.write("内 ...
- isNAN()的使用
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- [图形学] 习题8.12 NLN二维线段裁剪算法实现
Nicholl-Lee-Nicholl二维线段裁剪算法相对于Cohen-Sutherland和Liang-Barsky算法来说,在求交点之前进行了线段端点相对于几个区域的判断,可以确切的知道要求交点的 ...
- 刨根究底字符编码之十四——UTF-16究竟是怎么编码的
UTF-16究竟是怎么编码的 1. 首先要注意的是,代理Surrogate是专属于UTF-16编码方式的一种机制,UTF-8和UTF-32是不用代理的. 如前文所述,为了让UTF-16能继续编码基本平 ...
- Debian 8添加kali更新源并安装metasploit
一.Debian 8添加kali更新源 中科大kali更新源: deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contr ...
- RabbitMQ系列教程之六:远程过程调用(RPC)
远程过程调用(Remote Proceddure call[RPC])(本实例都是使用的Net的客户端,使用C#编写) 在第二个教程中,我们学习了如何使用工作队列在多个工作实例之间分配耗时的任务. ...