Advertisement
Guest User

Turing 12-2

a guest
Dec 5th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.   char c[1000000];
  7.   int len, s, i, j, k, max, ano;
  8.   while(scanf("%s\n", c) != EOF) {
  9.     len = strlen(c);
  10.     s = len/2;
  11.     max = 1;
  12.     ano = 0;
  13.     for(i = 2; i < len+1; i++) {
  14.       if(len%i)
  15.         continue;
  16.       s = len/i;
  17.       ano = 1;
  18.       for(j = 1; ano & (j < i); j++) {
  19.         for(k = 0; k < s; k++) {
  20.           if(c[k] != c[k + j*s]) {
  21.             ano = 0;
  22.             break;
  23.           }
  24.         }
  25.       }
  26.       if(ano)
  27.         max = i;
  28.     }
  29.     printf("%d\n", max);
  30.   }
  31.  
  32.   return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement