字符串匹配(KMP算法)
2015-08-22 13:21
246 查看
Input
The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:
One line with the word W, a string over {'A', 'B', 'C', …, 'Z'}, with 1 ≤ |W| ≤ 10,000 (here |W| denotes the length of the string W).
One line with the text T, a string over {'A', 'B', 'C', …, 'Z'}, with |W| ≤ |T| ≤ 1,000,000.
Output
For every test case in the input file, the output should contain a single number, on a single line: the number of occurrences of the word W in the text T.
Sample Input
Sample Output
The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:
One line with the word W, a string over {'A', 'B', 'C', …, 'Z'}, with 1 ≤ |W| ≤ 10,000 (here |W| denotes the length of the string W).
One line with the text T, a string over {'A', 'B', 'C', …, 'Z'}, with |W| ≤ |T| ≤ 1,000,000.
Output
For every test case in the input file, the output should contain a single number, on a single line: the number of occurrences of the word W in the text T.
Sample Input
3 BAPC BAPC AZA<div>AZAZAZA</div>VERDI AVERDXIVYERDIAN
Sample Output
1 3 0<div></div>
相关文章推荐
- web mysql 数据库分离,加载模块
- DispatcherHelper
- EventToCommand
- java 字节流和字符流的区别
- HDOJ GCD 2588【欧拉函数】
- 基于Google Material Design设计开发,模块包括图片浏览,视频爽看 ,音乐轻听以及二维码扫描
- iOS程序框架设计之皮肤切换功能
- Mvvm简介
- Messenger
- ViewModelLocator
- Font 根据路径返回字体(TTF)
- macbook下安装tesseract
- 关于SQL语句中SUM函数返回NULL的解决办法
- 洛谷1085 不高兴的津津
- 烂泥:高负载均衡学习haproxy之安装与配置
- RelayCommand
- ViewModelBase && ObservableObject
- LeetCode - Longest SubString without repeating characters_003
- WordPress For SAE进入后台
- MvvmLight ToolKit 教程