Advertisement
Ritam_C

D

Mar 6th, 2022
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. typedef unsigned long long ull;
  4. #define vi vector<int>
  5. #define vll vector<ll>
  6. #define tests int t; cin >> t; while(t--)
  7. #define pb push_back
  8. using namespace std;
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(false);
  12.     cin.tie(NULL); cout.tie(NULL);
  13.     tests {
  14.         int n, c; cin >> n >> c;
  15.         vi arr(c+1, 0);
  16.         for(int i = 0; i < n; i++) {
  17.             int x; cin >> x;
  18.             arr[x] = x;
  19.         }
  20.         if(arr[1] == 0) {
  21.             cout << "No\n";
  22.             continue;
  23.         }
  24.         bool f = 1;
  25.         for(int i = c-1; i >= 1; i--)
  26.             if(arr[i] == 0) arr[i] = arr[i+1];
  27.         for(int i = 2; i <= c; i++) {
  28.             if(arr[i] == i) {
  29.                 for(int j = i; j <= c; j += i) {
  30.                     if(arr[j] && arr[j]/arr[arr[j]/i] != i) {
  31.                         f = 0;
  32.                         break;
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.         if(f) cout << "Yes\n";
  38.         else cout << "No\n";
  39.     }
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement