(find) nyoj5-Binary String Matching
5-Binary String Matching
内存限制:64MB 时间限制:3000ms 特判: No
通过数:232 提交数:458 难度:3
题目描述:
输入描述:
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 可以用find。
注意用getchar()。。。。。。。
C++代码:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
int T;
scanf("%d",&T);
getchar(); //必须加上
while(T--){
string s1;
string s2;
getline(cin,s1);
getline(cin,s2);
int ans = s2.find(s1,);
int num = ;
while(ans >= ){
num++;
ans = s2.find(s1,ans+);
}
printf("%d\n",num);
}
return ;
}
(find) nyoj5-Binary String Matching的更多相关文章
- 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 ...
- Binary String Matching
问题 B: Binary String Matching 时间限制: 3 Sec 内存限制: 128 MB提交: 4 解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...
- NYOJ之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
- 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 ...
- NYOJ 5 Binary String Matching
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 ...
- 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(string)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
随机推荐
- centos无网络问题
- environment variable
%ALLUSERSPROFILE% C:\ProgramData %APPDATA% C:\Users\cuthead\AppData\Roaming %COMMONPROGRAMFILES% C:\ ...
- DeepLearning网络设计总结
检测网络: 1. tiling层可以减少计算量,deconvolution相比tiling性能要好一些
- 学习 Civil 3D二次开发从哪儿开始?
1.1 从哪儿开始 对于多数的工程设计人员,不完全具备上节所述的各种条件.对于Civil 3D的应用可能比较熟悉:但对于计算机语言,只限于上学时所学的一点基础知识,步入工作岗位后与计算机语言基本无缘: ...
- OneinStack——PHP多版本共存
前言 我事先安装的是LNMP环境,PHP版本为7.2,但是现在环境需要一个PHP5.6,所以就准备安装个上版本,顺带写个安装教程,写完后我发现了原来有直接安装的命令!所以后面的内容大家可以忽略了!从配 ...
- 微信小程序——安装开发工具和环境【二】
准备 开发工具下载 获取APPID 安装工具 安装 接受协议 选择安装位置 等待安装完成 安装完成 选择项目 选择小程序 填写信息 确定 无误后,点击确定进入开发页面 建立普通快速启动模板界面
- P1091 合唱队形 最长上升子序列
思路:最长上升子序列 正着做一遍 倒着做一遍 然后 取最大值 #include<bits/stdc++.h> using namespace std; const int maxn=105 ...
- bzoj 2054: 疯狂的馒头(线段树||并查集)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2054 线段树写法: 点的颜色只取决于最后一次染的颜色,所以我们可以倒着维护,如果当前区间之前 ...
- gogs : 添加 ssh An error has occurred : addKey: fail to parse public key: exec: "ssh-keygen": executable file not found in %PATH% - exec: "ssh-keygen": executable file not found in %PATH%
服务器上缺少配置 ssh-keygen.exe的 环境变量.git的环境变量 在path 环境变量加上.重启gogs服务
- QML 用QSortFilterProxyModel实现搜索功能
搞了一晚上终于实现了,写个博客纪念一下吧. c++部分的代码: #include <QQmlApplicationEngine> #include <QQmlContext> ...