poj2406 Power Strings(kmp) 给出一个字符串,问这个字符串是一个字符串重复几次.要求最大化重复次数. 若当前字符串为S,用kmp匹配'\0'+S和S即可. #include <cstdio> #include <cstring> using namespace std; const int maxn=2e6+5; char s1[maxn], s2[maxn]; int n1, n2, nxt[maxn], ans; int main(){ while (~…
Seek the Name, Seek the Fame Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 12 Accepted Submission(s) : 7 Problem Description The little cat is so famous, that many couples tramp over hill an…
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11831 Accepted: 5796 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names t…
http://poj.org/problem?id=2752 Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14611 Accepted: 7320 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked…
Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative inte…
Description In whiteblack on blackwhite is written the utterance that has been censored by the Ministry of Truth. Its author has already disappeared along with his whole history, and now, while Big Brother is watching somebody else, you, as an ordina…
放一个模板在这里搞事情...... 学KMP的话找SYCstudio吧(博客链接) 代码(多组数据,\(O(n)\)求一个串是否在另一个串里出现过) #include<cstdio> #define R register const int N=1e5+9; char s[N],t[N]; int ne[N]; int main(){ ne[0]=-1; R int i,j; while(~scanf("%s%s",s,t)){ for(i=1;t[i];++i){ for…
Problem 2275 Game Accept: 62 Submit: 165Time Limit: 1000 mSec Memory Limit : 262144 KB Problem Description Alice and Bob is playing a game. Each of them has a number. Alice’s number is A, and Bob’s number is B. Each turn, one player can do one…