forked from anshuman8800/Interivew-Questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT_Primes.cpp
More file actions
50 lines (46 loc) · 931 Bytes
/
T_Primes.cpp
File metadata and controls
50 lines (46 loc) · 931 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
47
48
49
50
/*https://codeforces.com/contest/230/problem/B*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M = 1e9 + 7;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int isprime(double n)
{
if (ceil(n) != floor(n))
return 0;
int cnt = 0;
if (n == 1)
return 0;
int n1 = (int)round(n);
for (int i = 2; i * i <= (n1); i++)
if (n1 % i == 0)
cnt++;
if (cnt == 0 || n1 == 2)
return 1;
return 0;
}
int main()
{
int t = 1;
// cin>>t;
while (t--)
{
ll n;
cin >> n;
vector<ll> v(n);
REP(i, 0, n - 1)
cin >> v[i];
REP(i, 0, n - 1)
{
if (isprime(sqrt(v[i])))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
}