题目链接:
https://cn.vjudge.net/problem/UVA-455
Input
The first line oif the input file will contain a single integer N indicating how many test case that your
program will test followed by a blank line. Each test case will contain a single character string of up
to 80 non-blank characters. Two consecutive input will separated by a blank line.
Output
An integer denoting the smallest period of the input string for each input. Two consecutive output are
separated by a blank line.
Sample Input
1
HoHoHo
Sample Output
2
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char str[1001];
int main()
{
int T;
cin>>T;
while (T--) {
scanf("%s",str);
int len = strlen(str);
for (int i = 1 ; i <= len ; ++ i)
if (len%i == 0) {
int k;
for (k = i ; k < len ; ++ k)
if (str[k] != str[k%i])
break;
if (k==len) {
printf("%d\n",i);
break;
}
}
if (T) printf("\n");
}
return 0;
}