POJ 3461 Oulipo(KMP)
来源:互联网 发布:php 刷新重复提交表单 编辑:程序博客网 时间:2024/06/05 21:13
Oulipo
题目链接:
http://poj.org/problem?id=3461
解题思路:
字符串匹配。。。kmp即可快速求解。。。
AC代码:
#include <iostream>#include <cstdio>#include <string>#include <cstring>using namespace std;int Next[10005];char word[10005],text[1000005];void getnext(){ int j = 0,k = -1; int l = strlen(word); Next[0] = -1; while(j < l){ if(k == -1 || word[j] == word[k]){ j++;k++; Next[j] = k; } else k = Next[k]; }}void kmp(){ getnext(); int l1 = strlen(text),l2 = strlen(word); int i = 0,j = 0,sum = 0; while(i < l1){ if(j == -1 || text[i] == word[j]){ i++; j++; } else j = Next[j]; if(j == l2){ sum++; j = Next[j]; } } printf("%d\n",sum);}int main(){ int T; scanf("%d",&T); while(T--){ scanf("%s",word); scanf("%s",text); kmp(); } return 0;}
0 0
- POJ 3461 - Oulipo(KMP)
- POJ-3461 Oulipo(KMP)
- Poj 3461 Oulipo (KMP)
- POJ---3461-Oulipo(KMP)
- POJ 3461 Oulipo(KMP)
- POJ 3461 Oulipo(KMP)
- 【POJ 3461】Oulipo(kmp)
- poj 3461 Oulipo(KMP)
- poj 3461 Oulipo(KMP)
- poj 3461 Oulipo(KMP)
- POJ 3461 Oulipo(KMP)
- POJ 3461 Oulipo---kmp
- POJ 3461 Oulipo KMP
- poj 3461 Oulipo (KMP)
- POJ 3461 Oulipo ( KMP )
- POJ 3461 Oulipo KMP
- POJ 3461 Oulipo / KMP
- Oulipo - POJ 3461 KMP
- centos在没有网络连接的情况下安装rpm包
- hdoj 2066 一个人的旅行
- 我的日记之stl的stack的使用方式
- poj 3080 Blue Jeans 【KMP 暴力枚举】
- nvme 驱动详解 之1
- POJ 3461 Oulipo(KMP)
- C/C++编译预处理:宏定义指令、文件包含指令、条件编译指令和特殊符号处理
- 《影响力》- 行走社会须知的干货
- hdu5371 Hotaru's problem 2015年多校第七场C题 最长回文串
- Google之大规模分布式系统的监控基础架构Dapper
- 基于注解的 Spring MVC 简单入门
- Slim Span
- java网络编程基础
- UE4学习笔记(二):c++与蓝图的交互