Advertisement
SuitNdtie

The Repeated String mk 2

May 5th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     for(int t = 1 ; t <= 5 ; t ++){
  7.         char str[100010];
  8.         scanf(" %s",str);
  9.         int len = strlen(str);
  10.         int cnt = 0;
  11.         for(int size = 1 ; size <= len ; size ++){
  12.             bool check = true;
  13.             if(len % size != 0)continue;
  14.            
  15.             for(int i = size ; i < len && check ; i += size){
  16.                 for(int j = 0 ; j < size && check; j ++){
  17.                     if(str[i+j] != str[j])check = false;
  18.                 }
  19.             }
  20.             if(check)cnt++;
  21.         }
  22.         printf("%d\n",cnt);
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement