HzuWHF


私信TA

用户名:I7I08I9047

访问量:76426

签 名:

我RUN了

等  级
排  名 18
经  验 20459
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:

解题思路:



参考代码:

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

int main() {
	char str[1233]; cin >> str;
	int par = 2, len = strlen(str), ans = 1;

	while (par <= len) {
		if (len % par == 0) {
			bool match = true;
			int step = len / par, pos = step;
			while (pos < len) {
				for (int i = 0; i < step; i++)
					if (str[i] != str[pos + i]) {
						match = false; break;
					}
				if (!match)
					break;
				pos += step;
			}
			if (match)
				ans = par;
		}
		par++;
	}
	cout << ans << endl;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区