Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Created by Saidolda Bayan.
- Copyright (c) 2015 Bayan. All rights reserved.
- LANG: C++
- */
- #include <bits/stdc++.h>
- #define what_is(x) cerr << #x << " is " << x << "\n";
- #define _USE_MATH_DEFINES
- #define y1 lalka
- #define right napravo
- #define left nalevo
- #define pb push_back
- #define mp make_pair
- #define f first
- #define s second
- #define ll long long
- #define ull unsigned long long
- using namespace std;
- const int INF = (int)1e9+7, mod = (int)1e9+9, pw = 31, N = (int)1e5+123, M = (int)1e6+123;
- const double eps = 1e-11;
- //const long long INF = 1e18;
- int n, x, d[9000];
- bool used[9000];
- vector<int> pr;
- int main ()
- {
- ios_base::sync_with_stdio(0);cin.tie(NULL);
- //freopen(".in","r",stdin);
- //freopen(".out","w",stdout);
- cin>>n;
- for(int i=2; i<=8000; i++){
- if(!used[i]){
- pr.pb(i);
- for(ll j=i*1ll*i; j<=8000; j+=i) used[j] = 1;
- }
- }
- for(int i=0; i<pr.size(); i++){
- d[pr[i]] = 1;
- for(int j=2; j<=8000; j++){
- if(d[j] && d[j] < 4){
- if( !d[j|pr[i]] || d[j]+1<d[pr[i]|j] ) d[pr[i]|j] = d[j]+1;
- }
- }
- }
- for(int i=1; i<=n; i++){
- cin>>x;
- if(d[x])cout<<"YES\n";
- else cout<<"NO\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement