We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ff17949 + 8f11453 commit 8f98c5dCopy full SHA for 8f98c5d
cplusplus/prime/radensaleh_T-Primes.cpp
@@ -0,0 +1,37 @@
1
+#include <bitset>
2
+#include <iostream>
3
+#include <math.h>
4
+using namespace std;
5
+
6
+long long n, temp;
7
+bitset<10000005> bs;
8
9
+void sieve(long long x)
10
+{
11
+ bs.set();
12
+ bs[0] = bs[1] = 0;
13
+ for (long long a = 2; a <= x; a++)
14
+ if (bs[a])
15
+ for (long long b = a * a; b <= x; b += a)
16
+ bs[b] = 0;
17
+}
18
19
+bool T_Primes(long long x)
20
21
+ if (bs[(int)sqrt(x)] && (long long)sqrt(x) * (long long)sqrt(x) == x)
22
+ return true;
23
+ return false;
24
25
26
+int main()
27
28
+ sieve(10000000);
29
+ cin >> n;
30
+ while (n--) {
31
+ cin >> temp;
32
+ if (T_Primes(temp))
33
+ cout << "YES\n";
34
+ else
35
+ cout << "NO\n";
36
+ }
37
0 commit comments