Advertisement
Saleh127

cc ltime88 gcd

Sep 26th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12. ll a[10005],c[10005],d,e,f,i,j=0,k,l;
  13. cin>>d;
  14. for(i=1;i<=d;i++)
  15. {
  16. cin>>a[i];
  17. }
  18. for(i=1;i<=d;i++)
  19. {
  20. if(a[i]!=i)
  21. {
  22. if(__gcd(i,a[i])==a[i])
  23. {
  24. continue;
  25. }
  26. else j=1;
  27. }
  28. }
  29.  
  30. if(j) cout<<"NO"<<endl;
  31. else cout<<"YES"<<endl;
  32. }
  33.  
  34.  
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement