题目传送门
/*
题意:求一个串重复出现(>1)的位置
KMP:这简直和POJ_2406没啥区别
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-10 9:13:24
* File Name :POJ_1961.cpp
************************************************/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e6 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
int n;
int nex[MAXN];
char str[MAXN];
void get_nex(void) {
int i = , j = -; nex[] = -;
while (i < n) {
if (j == - || str[j] == str[i]) {
j++; i++;
if (i % (i - j) == && i / (i - j) > ) {
printf ("%d %d\n", i, i / (i - j));
}
nex[i] = j;
}
else j = nex[j];
}
}
int main(void) { //POJ 1961 Period
int cas = ;
while (scanf ("%d", &n) == ) {
if (!n) break;
scanf ("%s", &str);
printf ("Test case #%d\n", ++cas);
get_nex ();
puts ("");
}
return ;
}