CF576A.Vasya and Petya's Game
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.
Petya can ask questions like: "Is the unknown number divisible by number y?".
The game is played by the following rules: first Petya asks all the questions that interest him (also, he can ask no questions), and then Vasya responds to each question with a 'yes' or a 'no'. After receiving all the answers Petya should determine the number that Vasya thought of.
Unfortunately, Petya is not familiar with the number theory. Help him find the minimum number of questions he should ask to make a guaranteed guess of Vasya's number, and the numbers y__i, he should ask the questions about.
瓦西娅和佩佳正在玩一个简单的游戏。瓦西娅想了一个介于 1 和 n 之间的数 x,而佩佳试图猜出这个数。
佩佳可以提出如下形式的问题:“未知数是否能被数 y 整除?”
游戏规则如下:首先,佩佳一次性提出所有他感兴趣的问题(当然,他也可以一个问题都不问),然后瓦西娅对每个问题分别回答“是”或“否”。在收到全部答案后,佩佳必须据此确定瓦西娅所想的数。
不幸的是,佩佳并不熟悉数论。请帮助他找出为确保能猜出瓦西娅所想的数所需的最少问题个数,以及他应就哪些数 yi 提出问题。
输入格式
A single line contains number n (1 ≤ n ≤ 103).
一行包含一个数字 n(1 ≤ n ≤ 103)。
输出格式
Print the length of the sequence of questions k (0 ≤ k ≤ n), followed by k numbers — the questions y__i (1 ≤ y__i ≤ n).
If there are several correct sequences of questions of the minimum length, you are allowed to print any of them.
输出问题序列的长度 k(0 ≤ k ≤ n),然后输出 k 个数——即问题编号 yi(1 ≤ yi ≤ n)。
若存在多个长度最短的正确问题序列,你可以输出其中任意一个。
输入输出样例
输入#1
4
输出#1
3 2 4 3
输入#2
6
输出#2
4 2 4 3 5
说明/提示
The sequence from the answer to the first sample test is actually correct.
If the unknown number is not divisible by one of the sequence numbers, it is equal to 1.
If the unknown number is divisible by 4, it is 4.
If the unknown number is divisible by 3, then the unknown number is 3.
Otherwise, it is equal to 2. Therefore, the sequence of questions allows you to guess the unknown number. It can be shown that there is no correct sequence of questions of length 2 or shorter.
第一个样例测试的答案序列实际上是正确的。
如果未知数不能被该序列中的某个数整除,则未知数等于 1。
如果未知数能被 4 整除,则它为 4。
如果未知数能被 3 整除,则它为 3。
否则,它等于 2。因此,该问题序列能够让你猜出未知数。可以证明:不存在长度为 2 或更短的正确问题序列。
输入解题思路,AI测评打分。不知道怎么写?