文章目录
- AcWing 777. 字符串乘方
- AC代码
AcWing 777. 字符串乘方
本题链接:AcWing 777. 字符串乘方
本博客给出本题截图:
AC代码
代码:
#include <iostream> using namespace std; int main() { string str; while (cin >> str, str != ".") { int len = str.size(); for (int n = len; n; n -- ) if (len % n == 0) { int m = len / n; string s = str.substr(0, m); string r; for (int i = 0; i < n; i ++ ) r += s; if (r == str) { cout << n << endl; break; } } } return 0; }