标签:others rip out 并且 des lan 输入 efi family
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
1 #include <stdio.h> 2 #include <string.h> 3 4 char s[1000010]; 5 int next_[1000010]; 6 void getnext(){ 7 int i = 0, j = -1; 8 int len = strlen(s); 9 next_[0] = -1; 10 while (i < len){ 11 if (j == -1 || s[i] == s[j]) 12 next_[++ i] = ++ j; 13 else 14 j = next_[j]; 15 } 16 } 17 int main () 18 { 19 int n,i,j,f = 1; 20 while (~scanf("%d",&n),n) 21 { 22 scanf("%s",s); 23 getnext(); 24 printf("Test case #%d\n",f ++); 25 for (i = 1; i <= n; i ++) 26 if (next_[i]) // i-next_[i] 为循环节的长度 27 if (i%(i-next_[i])==0 && i/(i-next_[i])!=1) //判断输入的字符串能否由该循环节组成 28 printf("%d %d\n",i,i/(i-next_[i])); 29 printf("\n"); 30 } 31 return 0; 32 }
标签:others rip out 并且 des lan 输入 efi family
原文地址:http://www.cnblogs.com/yoke/p/6920609.html