1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <math.h> 5 using namespace std; 6 7 int main() 8 { 9 char word[100]; 10 scanf("%s",word); 11 int len = strlen(word); 12 for(int i = 1;i <= len;i ++) 13 { 14 if(len % i == 0) 15 { 16 int ok = 1; 17 for(int j = i;j < len;j ++) 18 { 19 if(word[j] != word[j % i]) 20 { 21 ok = 0; 22 break; 23 } 24 } 25 if(ok) 26 { 27 printf("%d\n",i); 28 break; 29 } 30 } 31 } 32 return 0; 33 }
时间: 2024-12-13 15:59:43