class Solution {
public:
bool repeatedSubstringPattern(string str) {
if(str.length() == 1)
return false;
cout<<str.length()<<endl;
int *pre = new int[str.length()+1];
pre[0] = -1;
int i = 0, j = 0;
for(i = 1; i < str.length(); ){
if(j == -1 || str[i] == str[j]){
pre[++i] = ++j;
}
else
j = pre[j];
}
int m = str.length()-pre[str.length()];
if( m == str.length() )return 0;
if(str.length() % m == 0)
return true;
return false;
}
};