Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
118267 彭士宝 幂字符串 C++ Wrong Answer 1 MS 276 KB 665 2025-04-26 14:49:53

Tests(0/1):


Code:

#include <iostream> #include <string> using namespace std; int findMaxN(string s) { int len = s.length(); for (int i = len / 2; i >= 1; i--) { if (len % i == 0) { string sub = s.substr(0, i); string repeated; for (int j = 0; j < len / i; j++) { repeated += sub; } if (repeated == s) { return len / i; } } } return 1; } int main() { string s; while (true) { cin >> s; if (s == ".") { break; } cout << findMaxN(s) << 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