Advertisement
Guest User

Untitled

a guest
Oct 21st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. /*
  2.  Created by Saidolda Bayan.
  3.  Copyright (c) 2015 Bayan. All rights reserved.
  4.  LANG: C++
  5.  */
  6. #include <bits/stdc++.h>
  7. #define what_is(x) cerr << #x << " is " << x << "\n";
  8. #define _USE_MATH_DEFINES
  9. #define y1 lalka
  10. #define right napravo
  11. #define left nalevo
  12. #define pb push_back
  13. #define mp make_pair
  14. #define f first
  15. #define s second
  16. #define ll long long
  17. #define ull unsigned long long
  18. using namespace std;
  19. const int INF = (int)1e9+7, mod = (int)1e9+9, pw = 31, N = (int)1e5+123, M = (int)1e6+123;
  20. const double eps = 1e-11;
  21. //const long long INF = 1e18;
  22.  
  23. int n, x, d[9000];
  24. bool used[9000];
  25. vector<int> pr;
  26. int main ()
  27. {
  28.     ios_base::sync_with_stdio(0);cin.tie(NULL);
  29.     //freopen(".in","r",stdin);
  30.     //freopen(".out","w",stdout);
  31.     cin>>n;
  32.     for(int i=2; i<=8000; i++){
  33.         if(!used[i]){
  34.             pr.pb(i);
  35.             for(ll j=i*1ll*i; j<=8000; j+=i) used[j] = 1;
  36.         }
  37.     }
  38.     for(int i=0; i<pr.size(); i++){
  39.         d[pr[i]] = 1;
  40.         for(int j=2; j<=8000; j++){
  41.             if(d[j] && d[j] < 4){
  42.                 if( !d[j|pr[i]] || d[j]+1<d[pr[i]|j] ) d[pr[i]|j] = d[j]+1;
  43.             }
  44.         }
  45.     }
  46.     for(int i=1; i<=n; i++){
  47.         cin>>x;
  48.         if(d[x])cout<<"YES\n";
  49.         else cout<<"NO\n";
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement