比赛 4043级NOIP2022欢乐赛8th 评测结果 AAAAATTATTTTATTAAAAAAA
题目名称 反素数 最终得分 63
用户昵称 yrtiop 运行时间 8.909 s
代码语言 C++ 内存使用 3.13 MiB
提交时间 2022-11-21 18:47:57
显示代码纯文本
#include <bits/stdc++.h>

int p[10] = {0 , 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23};
int n,ans,val,sum[10];

void get(int x,int y) {
	if(x > ans)ans = x,val = y;
	else if(x == ans)val = std::min(val , y);
}

void dfs(int x) {
	if(x > n / 2) {
		int cnt = 1;
		for(int i = 1;i <= 9;++ i)cnt *= (sum[i] + 1);
		get(cnt , x);
		return ;
	}
	for(int i = 1;i <= 9;++ i) {
		if(x <= n / p[i])
			++ sum[i],dfs(x * p[i]),-- sum[i];
	}
	return ;
}

int main() {
	freopen("ant.in","r",stdin);
	freopen("ant.out","w",stdout);
	scanf("%d",&n);
	dfs(1);
	printf("%d\n",val);
	return 0;
}