The Minimum Length Problem's Link: http://acm.hust.edu.cn/problem/show/1010 Mean: 给你一个字符串,求这个字符串的最小循环节. analyse: KMP之next数组的运用.裸的求最小循环节. Time complexity: O(N) Source code:  ;;;);      ;}/* */…
<题目链接> 题目大意: 有一个字符串A,一次次的重写A,会得到一个新的字符串AAAAAAAA.....,现在将这个字符串从中切去一部分得到一个字符串B,例如有一个字符串A="abcdefg".,复制几次之后得到abcdefgabcdefgabcdefgabcdefg....,现在切去中间红色的部分,得到字符串B,现在只给出字符串B,求出字符串A的长度.  解题分析: 不难发现,本题A的定义其实就是字符串中最短循环节的定义,所以直接用KMP求出B字符串中的循环节即可. #i…
题意: 有一个字符串A,假设A是“abcdefg”,  由A可以重复组成无线长度的AAAAAAA,即“abcdefgabcdefgabcdefg.....”. 从其中截取一段“abcdefgabcdefgabcdefgabcdefg”,取红色部分为截取部分,设它为字符串B. 现在先给出字符串B, 求A最短的长度. 分析: 设字符串C = AAAAAAAA....  由于C是由无数个A组成的,所以里面有无数个循环的A, 那么从C中的任意一个起点开始,也都可以有一个循环,且这个循环长度和原来的A一样…
题意 有一个字符串A,一次次的重写A,会得到一个新的字符串AAAAAAAA.....,现在将这个字符串从中切去一部分得到一个字符串B.例如有一个字符串A="abcdefg".,复制几次之后得到abcdefgabcdefgabcdefgabcdefg....,现在切去中间红色的部分,得到字符串B,现在只给出字符串B,求出字符串A的最小长度. 思路 容易发现这个"循环节"是可以"旋转"的.即上述的"abcdefg"也可以是&quo…
F - The Minimum Length Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status Description There is a string A. The length of A is less than 1,000,000. I rewrite it again and again. Then I got a new string: AAAAAA...…
1.赤裸裸的最小循环节 2. 3. #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MAXN 1000005//字符串长度 int _next[MAXN]; void GetNext(char t[]){//求next数组 int j,k,len; j=;//从0开始,首先求_next[1] k=-;//比较指针 _next[]=-;//初始值-1…
There is a string A. The length of A is less than 1,000,000. I rewrite it again and again. Then I got a new string: AAAAAA...... Now I cut it from two different position and get a new string B. Then, give you the string B, can you tell me the length…
经典问题 : 给出一个由某个循环节构成的字符串,要你找出最小的循环节,例如 abababab 最小循环节当是 ab ,而类似 abab 也可以成为它的循环节,但并非最短. 分析 : 对于上述问题有两个结论 如果对于next数组中的 i, 符合 i % ( i - next[i] ) == 0 && next[i] != 0 , 则说明字符串循环,而且 循环节长度为:    i - next[i] 循环次数为:       i / ( i - next[i] ) 水平有限,用自己的语言描述怕…
Period Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 14653   Accepted: 6965 Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the…
                                                                                                  Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 38038   Accepted: 15740 Description Given two strings a and b we define a*b t…