B-POJ 2406 hash


Given two stinings a and b we define a*b to be their concateation.For example、if="abc"andb="def"the n a*b="abcdef".If wethininininininininininininininininamltipcation、exponentiation=="aaaaatttttttttinininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininin)
Input
Each test case is a line of input representing s,a string of printable characters.The length of s will be at least 1 and will not exceed 1 milion characters.A line containing a period follows the last test case.
Output
For each s you shoul d print the larget n such that=a^n for some string a.
Sample Input
abcd
aaaa
ababab
.
Sample Output
1
4
3
ベント
This problem has huge input、use scanf instead of cin to avoid time limit exced.
いくつかの文字列を入力して、各文字列に対して最短の循環節を求めて、彼が最大でいくつかの同じ連続するサブストリングで連結されることを求めます.
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef unsigned long long ull;
const int N = 1000000+10;
const int p = 131;
char str[N];
ull idx[N], hash[N];
int main()
{
    idx[0] = 1;
    //idx    p n  ;
    for(int i=1; i