思路:
利用周期。从周期为1到周期为size()循环
陷阱:
输出很坑。要求两个输出之前空一行,第一行之前不空。如图:

微信图片_20200101213959.png
#include <iostream>
using namespace std;
int main()
{
FILE *fin=freopen("xt3-4in.txt","r",stdin);
int t;string str;
cin >> t;
while (t--)
{
cin >> str;
int k = str.size();
for (unsigned i = 1; i <= str.size(); i++)
{
bool bol = false;
if (str.size() % i != 0)
continue;
for (unsigned j = 0; j != str.size() - i; j++)
{
if (str[j] != str[j + i])
bol = true;
}
if (bol)
continue;
k = i;
break;
}
cout << k << endl;
if (t)
cout << endl;
}
}