-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path465-different-divisors.cpp
More file actions
71 lines (66 loc) · 1.4 KB
/
Copy path465-different-divisors.cpp
File metadata and controls
71 lines (66 loc) · 1.4 KB
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
/*
* Different Divisors [1474B]
* Problem: https://codeforces.com/problemset/problem/1474/B
* Verdict: ACCEPTED Solved: 2021-01-19
* Language: C++17 (GCC 7-32)
* Runtime: 46 ms Memory: 200 KB
* Tags: binary search, constructive algorithms, greedy, math, number theory
* Author: BidoTeima
* Source: https://codeforces.com/contest/1474/submission/104848871
*/
#include <iostream>
#include <vector>
using namespace std;
/// Just wanted to see tags of the problem lol
void solve()
{
int x;
cin >> x;
vector<int> p;
for (int i = x + 1; ; i++)
{
int t = 1;
for (int j = 2; j * j <= i; j++)
{
if (i % j == 0)
{
t = 0;
break;
}
}
if (t)
{
p.push_back(i);
break;
}
}
for (int i = p.back() + x; ; i++)
{
int t = 1;
for (int j = 2; j * j <= i; j++)
{
if (i % j == 0)
{
t = 0;
break;
}
}
if (t)
{
p.push_back(i);
break;
}
}
/// Just wanted to see tags of problem lol
cout << min(1ll * p[0] * p[1], 1ll * p[0] * p[0] * p[0]) << "\n";
}
int main()
{
int t;
cin >> t;
while (t--)
{
/// Just wanted to see tags of problem lol
solve();
}
}