解题思路:
参考代码:
#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 人评分