-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDistinctPrimes.cpp
60 lines (47 loc) · 1.11 KB
/
DistinctPrimes.cpp
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
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
template<typename T> T gcd(T a, T b) {
if(!b) return a;
return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
return a * b / gcd(a, b);
}
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }
using namespace std;
typedef long long Int;
typedef unsigned uint;
int T;
vector<int> L;
void build(void) {
int i;
int cnt = 0;
for (i = 0; cnt <= 1000; i++) {
int x = i;
int curr = 2;
int dist = 0;
while (x > 1) {
bool ok = false;
while (x % curr == 0) {
x /= curr;
ok = true;
}
if (ok) dist += 1;
curr += 1;
}
if (dist >= 3) {
cnt += 1;
L.push_back(i);
}
}
}
int main(void) {
build();
T = in();
for ( ; T--; ) {
int x = in();
printf("%d\n", L[x-1]);
}
return 0;
}