Saleh127

CF 1401C

Aug 21st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);cout.tie(0);
  8.  
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. int x[200000],y[200000],d,e,f=0,i,m,n,o;
  14. cin>>d;
  15. for(i=0;i<d;i++)
  16. {
  17. cin>>x[i];
  18. y[i]=x[i];
  19. }
  20. sort(y,y+d);
  21.  
  22. e=y[0];
  23. for(i=0;i<d;i++)
  24. {
  25. if(x[i]!=y[i])
  26. {
  27. if(x[i]%e!=0)
  28. {
  29. f=1;
  30. break;
  31. }
  32. }
  33. }
  34. if(f==0) cout<<"YES"<<endl;
  35. else cout<<"NO"<<endl;
  36. }
  37. return 0;
  38. }
  39.  
Add Comment
Please, Sign In to add comment