-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeForce-RoundTableKnight.java
More file actions
35 lines (33 loc) · 999 Bytes
/
CodeForce-RoundTableKnight.java
File metadata and controls
35 lines (33 loc) · 999 Bytes
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
import java.util.ArrayList;
import java.util.Scanner;
public class RoundTableKnight {
public static void main(String...Args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Boolean flag = true;
ArrayList<Boolean> table = new ArrayList<Boolean>();
for (int i =0;i<n;i++){
table.add(sc.nextInt()==1 ? true:false);
}
sc.close();
for(int i=3; i<= n; i++){
if(n%i == 0){
int k = n/i;
for(int z=0; z<k;z++){
flag = true;
for (int j =0; j<i; j++){
if(table.get(z+j*k) == false){
flag = false;
}
}
if(flag){
System.out.println("YES");
return;
}
}
}
}
System.out.println("NO");
return;
}
}