ACM 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 <vector>
#include <string> using namespace std; int main(){
int n;
cin >>n;
while(n--){
string a,b;
cin >> a>>b;
size_t pos = ;
int cnt = ;
while((pos= b.find(a,pos))!=string::npos){
cnt++;
pos++;
}
cout<<cnt<<endl;
}
}
ACM Binary String Matching的更多相关文章
- 【ACM】Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- NYOJ之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
- Binary String Matching
问题 B: Binary String Matching 时间限制: 3 Sec 内存限制: 128 MB提交: 4 解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...
- Binary String Matching(kmp+str)
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 ...
- nyoj 题目5 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 ...
- nyoj 5 Binary String Matching(string)
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 alp ...
随机推荐
- 查看当前文件系统 df -lhT -B G
[root@ok-T test]# df -lhT -B G Filesystem Type 1G-blocks Used Available Use% Mounted on /dev/mapper/ ...
- WPF控件
1:内容控件(Content Controls)2:条目控件(Items Controls)3:文本控件(Text Controls)4:范围控件(Range Controls) 一:内容控件 内容控 ...
- sdut 2498【aoe 网上的关键路径】
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2498 代码超时怎么破: #include< ...
- git 创建本地分支,然后推送到服务器上
git checkout -b crm-2.repair-callback.phoneSet git checkout -b crm-2.repair-callback.RepairHis git p ...
- Quartz:Cron Expressions
原文地址:http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/crontrigger.html 注意: 位也可能是7位, ...
- Linux重置root密码步骤
1.开机时任意按一个方向键,进入界面,选择linux系统,按e键进入2.然后用上下键选择kerner(内核)那一行,按e键进入编辑界面,编辑界面最后一行显示如下:(grub edit> kern ...
- Win10 安装Vs2015 社区版和企业版各个问题汇总
1.前提下已经下载ISO文件 2.你的电脑没有连接网络或者你使用了宽带通类似的运营商网络. 3.你确保你正确安装了win10 并且已经激活 出现的问题如下 一.当你安装离线下载的ISO for Vs2 ...
- wp8 入门到精通 Utilities类 本地存储+异步
public class CCSetting { public async static void AddOrUpdateValue<T>(string key, T value) { t ...
- wp8 入门到精通 高仿微信发信息 键盘不消失
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> < ...
- CodeIgniter类的使用
Email 类 在配置文件中设置 Email 参数 如果您不想使用使用上述方法设定参数,您可以把它们放入一个配置文件.创建一个新文件称为email.php ,添加$config数组在该文件中.然后将该 ...