// UVa 455 - Periodic Strings #include <iostream> #include <string> using namespace std; int main() { int t; for (cin >> t; t; t--) { string s; cin >> s; int n = s.length(); int sol; for (int i = 1; i <= n; i++) if (n % i == 0) { bool found = true; for (int j = i; j < n; j++) { if (s[j] != s[j % i]) { found = false; break; } } if (found) { sol = i; break; } } cout << sol << endl; if (t > 1) cout << endl; } return 0; }
No comments:
Post a Comment