-
Notifications
You must be signed in to change notification settings - Fork 0
/
71_C.cpp
77 lines (70 loc) · 985 Bytes
/
71_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
bool good(int k,vector<int>&a)
{
int n = (int)a.size();
int c = n/k;
for(int j=1;j<=(int)a.size();j++)
{
bool good = true;
int count = 0;
int temp = j;
//cout<<" Separator "<<endl;
while(count<c)
{
// cout<<temp<<" "<<k<<" "<<n<<" "<<j<<endl;
if(a[temp] == 0)
{
good = false;
break;
}
temp = temp + k;
if(temp>=n)
{
temp = temp%(n-1);
}
count++;
}
if(good)
{
//cout<<k<<" gg "<<j<<endl;
return true;
}
}
return false;
}
int main()
{
int n;
cin>>n;
vector<int>a(n+1);
for(int i=1;i<n+1;i++)
{
cin>>a[i];
}
bool found = false;
for(int i=1;i<=sqrt(n);i++)
{
if(found)
{
break;
}
if(n%i==0)
{
//cout<<"dwdw"<<endl;
int k = n/i;
if(k>=3 && good(i,a))
found = true;
k = i;
if(k>=3 && good(n/i,a))
found = true;
}
}
if(!found)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
return 0;
}