Skip to content

Commit d47f694

Browse files
authored
Create GCD operations.java
1 parent 8f1d27f commit d47f694

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
class Codechef
6+
{
7+
static class FastReader
8+
{
9+
BufferedReader br;
10+
StringTokenizer st;
11+
12+
public FastReader()
13+
{
14+
br = new BufferedReader(new
15+
InputStreamReader(System.in));
16+
}
17+
18+
String next()
19+
{
20+
while (st == null || !st.hasMoreElements())
21+
{
22+
try
23+
{
24+
st = new StringTokenizer(br.readLine());
25+
}
26+
catch (IOException e)
27+
{
28+
e.printStackTrace();
29+
}
30+
}
31+
return st.nextToken();
32+
}
33+
34+
int nextInt()
35+
{
36+
return Integer.parseInt(next());
37+
}
38+
39+
long nextLong()
40+
{
41+
return Long.parseLong(next());
42+
}
43+
44+
double nextDouble()
45+
{
46+
return Double.parseDouble(next());
47+
}
48+
49+
String nextLine()
50+
{
51+
String str = "";
52+
try
53+
{
54+
str = br.readLine();
55+
}
56+
catch (IOException e)
57+
{
58+
e.printStackTrace();
59+
}
60+
return str;
61+
}
62+
}
63+
public static void main (String[] args) throws java.lang.Exception
64+
{
65+
// your code goes here
66+
FastReader sc=new FastReader();
67+
int t=sc.nextInt();
68+
while(t-->0) {
69+
int n=sc.nextInt();
70+
int[] b=new int[n];
71+
for(int i=0;i<n;i++) {
72+
b[i]=sc.nextInt();
73+
}
74+
int flag=0;
75+
for(int i=0;i<n;i++) {
76+
if((i+1)%b[i]!=0) {
77+
flag=1;
78+
break;
79+
}
80+
}
81+
if(flag==1) {
82+
System.out.println("NO");
83+
}
84+
else {
85+
System.out.println("YES");
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)