-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGCDOPS.java
More file actions
32 lines (29 loc) · 837 Bytes
/
Copy pathGCDOPS.java
File metadata and controls
32 lines (29 loc) · 837 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
import java.util.*;
class Codechef {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int q = 0; q < t; q++) {
int n = sc.nextInt();
int a[] = new int[n];
int b[] = new int[n];
for(int i=0; i<n; i++){
a[i] = i+1;
b[i] = sc.nextInt();
}
int flag=0;
for(int i=0; i<n; i++){
if(a[i]!=b[i]){
if(a[i]%b[i]!=0){
System.out.println("NO");
flag=1;
break;
}
}
}
if(flag==0){
System.out.println("YES");
}
}
}
}