8 条题解

  • 1
    @ 2025-1-14 22:34:29

    简单暴力,不必多言

    #include <iostream>
    #include <vector>
    using namespace std;
    int main(){
        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        int n;
        cin >> n;
        string s;
        cin >> s;
        for(int i = 1 ; i <= n ; i++){
            if(n % i == 0){
                string ss = "";
                for(int j = 1 ; j <= i ; j++){
                    ss += s[j - 1];
                }
                string p = "";
                int x = n / i;
                while(x--){
                    p += ss;
                }
                if(p == s){
                    cout << i;
                    break;
                }
            }
        }
        return 0;
    }
    

    信息

    ID
    49
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    (无)
    递交数
    1615
    已通过
    388
    上传者