- 浏览: 121808 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 3122回溯法是设计递归过程的一种重要方法,它的求解过程是遍历一个状态 ... -
螺旋矩阵
2011-10-19 13:26 957给一个正整数n,输出一个n*n的螺旋矩阵 螺旋矩阵可以是逆时针 ... -
HDU2896(病毒侵袭)
2011-09-26 13:46 860病毒侵袭 Time Limit: 2000/1 ... -
HDU 2203(亲和串)
2011-09-26 13:10 1046亲和串 Time Limit: 3000/1000 MS (J ... -
HDU2060(Snooker)
2011-09-17 19:20 866Snooker Time Limit: 1000/1000 M ... -
HDU1166(敌兵布阵)
2011-09-17 12:55 802敌兵布阵 Time Limit: 2000/1000 MS ( ... -
HDU1754 I Hate It
2011-09-16 23:40 1023参考资料:http://www.cppblog.com/MiY ... -
HDU2100Lovekey
2011-09-12 17:16 690Lovekey Time Limit: 3000/1000 M ... -
HDU3368 Reversi(黑白棋)
2011-09-11 23:04 1028Reversi Time Limit: 5000/2000 M ... -
HDU1010Tempter of the Bone
2011-09-11 23:02 524Tempter of the Bone Time Limit: ... -
求一个集合的全排列
2011-09-11 14:49 775#include <iostream> usin ... -
HDU1175连连看
2011-09-09 23:24 753连连看 Time Limit: 20000/10000 MS ... -
HDU1711Number Sequence
2011-09-09 13:09 713Number Sequence Time Limit: 100 ... -
串的模式匹配算法
2011-09-07 14:01 648c实现 #include <iostream> ... -
HDU1097A hard puzzle
2011-09-06 22:46 819A hard puzzle Time Limit: 2000/ ... -
串的顺序实现
2011-09-06 11:26 819串的顺序实现 串的顺序结构实现有弊端: 1.串的最大长度固定 ... -
HDU1004Let the Balloon Rise
2011-09-06 09:44 509Let the Balloon Rise Time Limit ... -
HDU2061Treasure the new start, freshmen!
2011-08-24 14:06 986Treasure the new start, freshme ... -
HDU2251Seinfeld
2011-08-24 13:39 876Seinfeld Time Limit: 2000/1000 ... -
HDU2083简易版之最短距离
2011-08-22 15:30 892简易版之最短距离 Time Limit: 1000/1000 ...
相关推荐
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
HDU1059的代码
杭电ACMhdu1163
hdu1001解题报告
HDU的一题........HDU DP动态规
hdu 1574 passed sorce
hdu acm 教案 搜索入门 hdu acm 教案 搜索入门
hdu2101AC代码
搜索 dfs 解题代码 hdu1241
ACM HDU题目分类,我自己总结的大概只有十来个吧
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
hdu-acm源代码(上百题)hdu-acm源代码、hdu-acm源代码hdu-acm源代码
HDU最全ac代码
hdu动态规划算法集锦
hdu 1166线段树代码
hdu题目分类
HDU图论题目分类
hdu 1005.比较简单的一道题,有兴趣的可以看看。
ACM HDU 2000->2099 解题报告 ACM HDU 2000->2099 解题报告 ACM HDU 2000->2099 解题报告