Untitled

 avatar
user_5668965
c_cpp
15 days ago
953 B
1
Indexable
Never
#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    std::vector<bool> check(n+1);
    
    for (int i = 3; i <= n; i++) {
        if (check[i]) {
            continue;
        }
        if (n % i) {
            continue;
        }
        for (int j = i; j <= n; j += i) {
            check[j] = true;
        }
        
        for (int k = 0; k < n/i; k++) {
            bool ok = true;
            for (int x = k; x < n; x += n/i) {
                if (!a[x]) {
                    ok = false;
                }
            }
            if (ok) {
                std::cout << "YES\n";
                return 0;
            }
        }
    }
    std::cout << "NO\n";
    
    return 0;
}
Leave a Comment