POJ 3693 - Maximum repetition substring

The detail solution will be posted later. The proof is very long. (Using segment tree to optimize and the number theory to prove the correctness).