Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
136253 彭士宝 幂字符串 C++ Wrong Answer 2 MS 272 KB 667 2025-11-09 22:44:10

Tests(0/1):


Code:

#include <iostream> #include <string> using namespace std; int main() { string s; while (true) { 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); string repeated = ""; for (int j = 0; j < n / i; ++j) { repeated += sub; } if (repeated == s) { max_n = n / i; } } } cout << max_n << endl; } return 0; }


Run Info:

------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