【习题 3-4 UVA

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

枚举

【代码】

#include <bits/stdc++.h>
using namespace std;

const int N = 100;

char s[N];
int len;

bool check(int L)
{
	if (len%L != 0) return false;
	for (int i = L; i < len; i++)
		if (s[i] != s[i%L])
			return false;
	return true;
}

int main()
{
	//freopen("F:\rush.txt", "r", stdin);
	int T,kase=0;
	scanf("%d", &T);
	while (T--)
	{
		if (kase > 0) puts("");
		kase++;
		scanf("%s", s);
		len = strlen(s);
		for (int i = 1;i <= len;i++)
			if (check(i))
			{
				printf("%d
", i);
				break;
			}
	}
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7688200.html