forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(CodeChef) WATMELON.cpp
51 lines (45 loc) · 1009 Bytes
/
(CodeChef) WATMELON.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
/********************************************
********* Code By Sweta**********************
********************************************/
#include <iostream>
using namespace std;
void eval(){
int n;
cin>>n;
int ar[n];
bool k[n];
for(int i=0;i<n;i++){
cin>>ar[i];
k[i]=true;
}
for(int i=0;i<n;i++){
if(ar[i]!=i+1){
for(int j=1;j<=(i+1);j++){
if((i+1)%j==0 && j%j==0){
if(j==ar[i]){
k[i]=true;
break;
}
else
k[i]=false;
}
}
}
}
for(int i=0;i<n;i++){
if(k[i]==0){
cout<<"NO"<<endl;
break;
}
else if(k[i]==1 && i==n-1)
cout<<"YES"<<endl;
}
}
int main() {
int t;
cin>>t;
while(t--){
eval();
}
return 0;
}