CF1622F.Quadratic Set
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call a set of positive integers a1,a2,…,ak quadratic if the product of the factorials of its elements is a square of an integer, i. e. i=1∏kai!=m2, for some integer m.
You are given a positive integer n.
Your task is to find a quadratic subset of a set 1,2,…,n of maximum size. If there are multiple answers, print any of them.
我们称一个正整数集合 a1,a2,…,ak 是二次的(quadratic),如果其各元素的阶乘之积是一个整数的平方,即 i=1∏kai!=m2,其中 m 为某个整数。
给定一个正整数 n。
你的任务是在集合 {1,2,…,n} 中找出一个最大规模的二次子集。若存在多个满足条件的答案,输出任意一个即可。
输入格式
A single line contains a single integer n (1≤n≤106).
一行中包含一个整数 n(1≤n≤106)。
输出格式
In the first line, print a single integer — the size of the maximum subset. In the second line, print the subset itself in an arbitrary order.
第一行输出一个整数——最大子集的大小。
第二行以任意顺序输出该子集本身。
输入输出样例
输入#1
1
输出#1
1 1
输入#2
4
输出#2
3 1 3 4
输入#3
7
输出#3
4 1 4 5 6
输入#4
9
输出#4
7 1 2 4 5 6 7 9
输入解题思路,AI测评打分。不知道怎么写?