#include <cstdio>
#include <cstring>
int main(){
char word[100];
memset(word, '\0', sizeof(word));
scanf("%s", word);
int len = strlen(word);
for (int period = 1; period <= len / 2; ++period){
bool isFound = true;
for (int i = period; i < len; ++i){
if (word[i] != word[i % period]){
isFound = false;
break;
}
}
if (isFound){
printf("minPeriod=%d\n", period);
break;
}
}
printf("end\n");
return 0;
}
算法竞赛入门经典 5.1.3找串的最小重复周期
最新推荐文章于 2018-08-02 09:28:15 发布