-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathADTRI.cpp
More file actions
executable file
·46 lines (43 loc) · 772 Bytes
/
Copy pathADTRI.cpp
File metadata and controls
executable file
·46 lines (43 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
typedef long ll;
const ll N=5000002;
bool isPrime[N], isHyp[N];
vector<ll> prime;
void ansfunc() {
for(ll i=0;i<N;i++) {
isHyp[i]=false;
isPrime[i]=true;
}
//Sieve of Eratosthenes
isPrime[0] = isPrime[1] =false;
for(ll i=2; i<N; i++) {
if(isPrime[i])
for(ll j=i*2;j<N;j+=i)
isPrime[j]=false;
}
for(ll i=2;i<N;i++) {
if(isPrime[i] == true && i%4==1)
prime.push_back(i);
}
for(ll i=0;i<prime.size();i++) {
for(ll j=prime[i]; j<N; j+=prime[i])
isHyp[j]=true;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ansfunc();
ll t;
cin>>t;
while(t--) {
ll n;
cin>>n;
if(isHyp[n])
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}