-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAMR11E1.cpp
82 lines (61 loc) · 863 Bytes
/
AMR11E1.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 2505
#define NUM 50
std::vector<bool> arr(MAX);
std::vector<int> ans(2005);
int main()
{
int i;
bool flag=true;
for(int j=4;j<MAX;j+=2)
arr[j]=1;
for(int j=9;j<MAX;j+=6)
arr[j]=1;
for(i=5;i<NUM;)
{
if(!arr[i])
{
for(int j=i*i, k=(i<<1);j<MAX;j+=k)
arr[j]=1;
}
if(flag)
i+=2;
else
i+=4;
flag^=true;
}
int pos=1;
for(int n=30;pos<=1050;n++)
{
int cnt=0;
int n1=n;
int sqrtn=sqrt(n)+1;
for(int i=2;i<=sqrtn;i++)
{
if((!(arr[i]))&&(!(n1%i)))
{
cnt++;
while(!(n1%i))
n1=(n1/i);
if(cnt>=3)
break;
}
}
if(cnt>=3)
{
ans[pos]=n;
pos++;
}
}
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",ans[n]);
}
}