-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcrivo.cpp
More file actions
40 lines (37 loc) · 676 Bytes
/
crivo.cpp
File metadata and controls
40 lines (37 loc) · 676 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
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 100001
#define mod 1000000007
bitset <MAXN> prime;
void crivo ()
{
prime.set();
prime[0] = false;
prime[1] = false;
for (int i = 2 ; i < MAXN ; i++)
if(prime[i])
for(int j = 2 ; j * i < MAXN ; j++)
prime[j * i] = false;
}
signed main()
{
crivo();
int q;
cin >> q;
while(q--)
{
int n;
cin >> n;
(prime[n]) ? cout << "YES\n" : cout << "NO\n" ;
}
return 0;
}