-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.cpp
51 lines (50 loc) · 989 Bytes
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define err(a...) fprintf(stderr, a)
int main() {
int n;
scanf("%d", &n);
vector<int> a(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
auto Check = [&, n](int x) {
for (int i = 0; i < x; ++i) {
bool ok = true;
int cnt = 0;
for (int j = i; j < n; j += x) {
if (a[j] == 0) {
ok = false;
break;
}
++cnt;
if (j + x >= n) {
if ((j + x) % n != i) {
ok = false;
break;
}
}
}
if (ok && cnt > 2) {
return true;
}
}
return false;
};
auto Bye = [](bool b) {
if (b) {
puts("YES");
exit(0);
}
};
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
Bye(Check(i));
if (i * i != n) Bye(Check(n / i));
}
}
puts("NO");
return 0;
}