这道没做出来,我是菜狗
链接:https://ac.nowcoder.com/acm/contest/42105/F
来源:牛客网
Cuber QQ is finding the minimal interesting number. An interesting number xx satisfies:
xx is a positive integer;
xx has at least eight factors;
The difference between any two different factors of xx is not less than nn.
Now, Cuber QQ will give you nn, and ask you to find the least interesting number.
输入描述:
The first line contains an integer TT (1\le T\le 10001≤T≤1000), representing the number of test cases.
The following TT lines, each line contains an integer nn (1\le n\le 1000001≤n≤100000).
输出描述:
For each test case, output an integer representing the answer.
示例1
输入
复制
3
1
2
3
输出
复制
24
105
935
#include<bits/stdc++.h>
using namespace std;
bool judge(long long a) {
if(a == 1) return 1;
if(a == 2 || a == 3) return 1;
if(a%6 != 1 && a%6 != 5) return 0;
int sqrtA = sqrt(a);
for(int i = 5; i <= sqrtA; i += 6) {
if(!(a%i)|| !(a%(i+2))) return 0;
}
return 1;
}
int main() {
int t;
cin >> t;
while (t--) {
long long i = 1, j = 0, ans = 1,n;
cin >> n;
if (n == 1) {
cout << 24 << endl;
continue;
}
while (j < 4) {
if (judge(i)) {
ans *= i;
i += n;
j++;
}
else {
i++;
}
}
cout << ans << endl;
}
}