F-Factor Difference

这道没做出来,我是菜狗
链接: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;
		
		
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值