比赛 4043级NOIP2022欢乐赛8th 评测结果 AAAAAAAAAAAAAAAAAAAAAA
题目名称 反素数 最终得分 100
用户昵称 Lfc_HeSn 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-11-21 19:40:07
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, p[20] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}, ans, num;
void dfs(int x, int lst, int s, int w) {
//	cout << x << ' ' << lst << ' ' << s << ' ' << w << endl;
	if(w > num || (w == num && s < ans)) {
		ans = s;
		num = w;
	}
	int a = s;
	for(int i = 1; i <= lst; i ++) {
		if(n / a < p[x]) {
			return ;
		}
		a = a * p[x];
		if(i <= n) {
			dfs(x + 1, i, a, w * (i + 1));
		}
	}
}
signed main() {
	freopen("ant.in", "r", stdin);
	freopen("ant.out", "w", stdout);
	cin >> n;
	dfs(1, 30, 1, 1);
	cout << ans;
	return 0;
}