-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1474 B Different Divisors.cpp
76 lines (66 loc) · 1.83 KB
/
1474 B Different Divisors.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
/*Positive integer x is called divisor of positive integer y, if y is divisible by x without remainder. For example, 1 is a divisor of 7 and 3 is not divisor of 8.
We gave you an integer d and asked you to find the smallest positive integer a, such that
a has at least 4 divisors;
difference between any two divisors of a is at least d.
Input
The first line contains a single integer t (1≤t≤3000) — the number of test cases.
The first line of each test case contains a single integer d (1≤d≤10000).
Output
For each test case print one integer a — the answer for this test case.
Example
inputCopy
2
1
2
outputCopy
6
15*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
vector<ll>a;
for(ll i=n+1; ;i++)
{
bool find = true;
for(ll j=2;j*j<=i;j++)
{
if(i%j==0)
{
find=false;
break;
}
}
if(find)
{
a.push_back(i);
break;
}
}
for(ll i= a.back()+n;;i++)
{
bool find = true;
for(ll j=2;j*j<=i;j++)
{
if(i%j==0)
{
find=false;
break;
}
}
if(find)
{
a.push_back(i);
break;
}
}
cout<<min(a[0]*a[1],a[0]*a[0]*a[0])<<endl;
}
}