- 浏览: 125283 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
leelege:
让一切GenericDao都去死吧
自己写的一个Hibernate CURD的封装 -
liuxuejin:
不用泛型的飘过,个人觉得没有什么必要,因为增删查的代码(简单的 ...
自己写的一个Hibernate CURD的封装 -
java113096:
finallygo 写道icanfly 写道ricoyu 写道 ...
自己写的一个Hibernate CURD的封装 -
jiluo093:
http://jiluo093.iteye.com/blog/ ...
自己写的一个Hibernate CURD的封装 -
piao_bo_yi:
Dev|il 写道yin_bp 写道Dev|il 写道dnst ...
自己写的一个Hibernate CURD的封装
Oulipo
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1554 Accepted Submission(s): 587
Problem Description
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:
Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…
Perec would probably have scored high (or rather, low) in the following contest. People are asked to write a perhaps even meaningful text on some subject with as few occurrences of a given “word” as possible. Our task is to provide the jury with a program that counts these occurrences, in order to obtain a ranking of the competitors. These competitors often write very long texts with nonsense meaning; a sequence of 500,000 consecutive 'T's is not unusual. And they never use spaces.
So we want to quickly find out how often a word, i.e., a given string, occurs in a text. More formally: given the alphabet {'A', 'B', 'C', …, 'Z'} and two finite strings over that alphabet, a word W and a text T, count the number of occurrences of W in T. All the consecutive characters of W must exactly match consecutive characters of T. Occurrences may overlap.
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
3
BAPC
BAPC
AZA
AZAZAZA
VERDI
AVERDXIVYERDIAN
Sample Output
1
3
0
题意:找出被匹配串中能匹配目标串的个数
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1554 Accepted Submission(s): 587
Problem Description
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:
Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…
Perec would probably have scored high (or rather, low) in the following contest. People are asked to write a perhaps even meaningful text on some subject with as few occurrences of a given “word” as possible. Our task is to provide the jury with a program that counts these occurrences, in order to obtain a ranking of the competitors. These competitors often write very long texts with nonsense meaning; a sequence of 500,000 consecutive 'T's is not unusual. And they never use spaces.
So we want to quickly find out how often a word, i.e., a given string, occurs in a text. More formally: given the alphabet {'A', 'B', 'C', …, 'Z'} and two finite strings over that alphabet, a word W and a text T, count the number of occurrences of W in T. All the consecutive characters of W must exactly match consecutive characters of T. Occurrences may overlap.
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
3
BAPC
BAPC
AZA
AZAZAZA
VERDI
AVERDXIVYERDIAN
Sample Output
1
3
0
题意:找出被匹配串中能匹配目标串的个数
#include <iostream> using namespace std; const int _N = 1000005; const int _M = 10005; char a[_M], b[_N]; int next[_M]; int n, m; void getNext() { int i = 1, j = 0; next[1] = 0; while(i <= n) { if(j == 0 || a[i] == a[j]) { i++; j++; if(a[i] == a[j]) next[i] = next[j]; else next[i] = j; }else j = next[j]; } } int Index_KMP() { int i = 1, j = 1, num = 0; while(i <= m) { if(j == 0 || a[j] == b[i]) { ++i; ++j; }else j = next[j]; if(j == n + 1) { num++; j = next[j]; } } return num; } int main() { int t, i, cnt; cin>>t; while(t--) { getchar(); cin>>a + 1>>b + 1; a[0] = '#'; b[0] = '#'; cnt = 0; n = strlen(a) - 1; m = strlen(b) - 1; getNext(); cout<<Index_KMP()<<endl; } return 0; }
发表评论
-
求n个元素集合的子集(幂集)或n个元素的组合
2011-10-21 13:19 3203回溯法是设计递归过程的一种重要方法,它的求解过程是遍历一个状态 ... -
螺旋矩阵
2011-10-19 13:26 1018给一个正整数n,输出一个n*n的螺旋矩阵 螺旋矩阵可以是逆时针 ... -
HDU2896(病毒侵袭)
2011-09-26 13:46 930病毒侵袭 Time Limit: 2000/1 ... -
HDU 2203(亲和串)
2011-09-26 13:10 1082亲和串 Time Limit: 3000/1000 MS (J ... -
HDU2060(Snooker)
2011-09-17 19:20 910Snooker Time Limit: 1000/1000 M ... -
HDU1166(敌兵布阵)
2011-09-17 12:55 857敌兵布阵 Time Limit: 2000/1000 MS ( ... -
HDU1754 I Hate It
2011-09-16 23:40 1061参考资料:http://www.cppblog.com/MiY ... -
HDU2100Lovekey
2011-09-12 17:16 731Lovekey Time Limit: 3000/1000 M ... -
HDU3368 Reversi(黑白棋)
2011-09-11 23:04 1070Reversi Time Limit: 5000/2000 M ... -
HDU1010Tempter of the Bone
2011-09-11 23:02 559Tempter of the Bone Time Limit: ... -
求一个集合的全排列
2011-09-11 14:49 820#include <iostream> usin ... -
HDU1175连连看
2011-09-09 23:24 795连连看 Time Limit: 20000/10000 MS ... -
HDU1711Number Sequence
2011-09-09 13:09 744Number Sequence Time Limit: 100 ... -
串的模式匹配算法
2011-09-07 14:01 666c实现 #include <iostream> ... -
HDU1097A hard puzzle
2011-09-06 22:46 860A hard puzzle Time Limit: 2000/ ... -
串的顺序实现
2011-09-06 11:26 848串的顺序实现 串的顺序结构实现有弊端: 1.串的最大长度固定 ... -
HDU1004Let the Balloon Rise
2011-09-06 09:44 537Let the Balloon Rise Time Limit ... -
HDU2061Treasure the new start, freshmen!
2011-08-24 14:06 1014Treasure the new start, freshme ... -
HDU2251Seinfeld
2011-08-24 13:39 898Seinfeld Time Limit: 2000/1000 ... -
HDU2083简易版之最短距离
2011-08-22 15:30 920简易版之最短距离 Time Limit: 1000/1000 ...
相关推荐
【标题】"HDU_2010.rar"是一个压缩包文件,其中包含了与"HDU 2010"相关的资源,特别是针对"HDU ACM20"比赛的编程题目。"hdu 2010"和"hdu 20"可能是该比赛的不同简称或分类,而"hdu acm20"可能指的是该赛事的第20届...
HDU(杭州电子科技大学在线评测系统)是一个深受程序员喜爱的在线编程练习平台,它提供了丰富的算法题目供用户挑战,帮助他们提升编程技能和算法理解能力。"hdu.rar_hdu"这个压缩包文件很可能是某位程序员整理的他在...
【标题】"HDU题目java实现"所涉及的知识点主要集中在使用Java编程语言解决杭州电子科技大学(HDU)在线评测系统中的算法问题。HDU是一个知名的在线编程竞赛平台,它提供了大量的算法题目供参赛者练习和提交解决方案...
ACM HDU 题目分类 ACM HDU 题目分类是指对 HDU 在线判题系统中题目的分类,总结了大约十来个分类。这些分类将有助于编程选手更好地理解和解决问题。 DP 问题 DP(Dynamic Programming,动态规划)是一种非常重要...
### hdu1250高精度加法 #### 背景介绍 在计算机科学与编程竞赛中,处理大整数运算(特别是加法、减法、乘法等)是常见的需求之一。当数字的位数超过了标准数据类型(如`int`、`long`等)所能表示的最大值时,就需要...
【标题】"hdu.rar_HDU 1089.cpp_OJ题求和_hdu_horsekw5_杭电obj" 提供的信息是关于一个压缩文件,其中包含了一个名为 "HDU 1089.cpp" 的源代码文件,这个文件是为了解决杭州电子科技大学(Hangzhou Dianzi ...
【标题】"HDU DP动态规划"涉及到的是在算法领域中的动态规划(Dynamic Programming,简称DP)技术,这是解决复杂问题的一种高效方法,尤其适用于有重叠子问题和最优子结构的问题。动态规划通常用于优化多阶段决策...
HDU1059的代码
hdu1001解题报告
hdu 1574 passed sorce
【标题】"HDU.rar_hdu_hdu07_com_shownv9b_www.563hdu." 暗示这是一个与HDU(杭州电子科技大学在线编程平台)相关的压缩包,其中可能包含了该平台上的编程竞赛题目或练习题目的源代码。"hdu07"可能是某个特定题目的...
【ACM HDU】指的是在ACM(国际大学生程序设计竞赛,International Collegiate Programming Contest)中,参赛者在杭州电子科技大学(Hangzhou Dianzi University,简称HDU)的在线评测系统上完成并已解决的题目集合...
【标题】"hdu_acm_1084.rar_ACM_HDU10_acm10_hdu_hdu 1084" 提供的是一个关于杭电(HDU)ACM竞赛第1084题的解决方案。该题目可能是在编程竞赛中常见的算法问题,而ACM(国际大学生程序设计竞赛)是全球知名的编程...
【标题】:杭电ACMhdu1163 【描述】:这是一道源自杭州电子科技大学(Hangzhou Dianzi University,简称HDU)的ACM编程竞赛题目,编号为1163。这类问题通常需要参赛者利用计算机编程解决数学、逻辑或算法上的挑战,...
HDU是杭州电子科技大学(Hangzhou Dianzi University)举办的一个在线编程竞赛平台,全称为HDU Online Judge。ACM是国际大学生程序设计竞赛(International Collegiate Programming Contest)的缩写,是一个全球性的...
hdu2101AC代码
【ACM入门与提高:HDU ACM竞赛课程详解】 ACM(国际大学生程序设计竞赛,International Collegiate Programming Contest,简称ICPC或ACM/ICPC)是一项全球性的竞赛,旨在激发大学生对计算机科学的兴趣,提升他们的...
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
HDU(Hangzhou Dianzi University)是国内外知名的在线编程竞赛平台,主要服务于ACM/ICPC(国际大学生程序设计竞赛)以及相关的算法训练。"HDU最全ac代码"这个压缩包很可能是包含了在HDU平台上解题通过的完整源代码...
根据提供的信息,我们可以总结出以下关于“hdu动态规划算法集锦”的知识点: ### 动态规划基础概念 动态规划是一种解决多阶段决策问题的方法,它通过将原问题分解为互相重叠的子问题,利用子问题的解来构建原问题...