| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 136255 | 彭士宝 | 幂字符串 | C++ | Wrong Answer | 2 MS | 272 KB | 754 | 2025-11-09 22:46:37 |
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { if (s == ".") break; int n = s.length(); int max_n = 1; for (int i = 1; i <= n / 2; ++i) { if (n % i == 0) { string sub = s.substr(0, i); bool is_valid = true; for (int j = 0; j < n; j += i) { if (s.substr(j, i) != sub) { is_valid = false; break; } } if (is_valid) { max_n = n / i; } } } cout << max_n << endl; } return 0; }
------Input------
asdfghj aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f ..... asasasasasasasas abcabcabcabc ,,..,,..,,.. a.a.a.a.a.a.a. asdfghjklasdfghjkl ooooooooooooooooooooooppppppppppppppppppppppppppp .
------Answer-----
1 100 1 5 8 4 3 7 2 1
------Your output-----
1 2 1 5 2 2 3 7 2 1