302957: CF576A. Vasya and Petya's Game
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vasya and Petya's Game
题意翻译
给定一个数字 $n$,现在 Vasya 要从 $1\sim n$ 中想一个数字 $x$。 Petya 向 Vasya 询问 “$x$ 是否能整除 $y$?” ,通过 Vasya 的回答来判断 $x$ 的答案。 Petya 的问题一开始就已经准备好,**他必须将所有问题都问一遍**,不管他当前需不需要问。 他想知道无论 Vasya 想出任何的 $x$, 最少要准备多少次询问 $y$ 的问题才能猜中 $x$,并输出一组具体方案。 $n\leq 1000$题目描述
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.输入输出格式
输入格式
A single line contains number $ n $ ( $ 1<=n<=10^{3} $ ).
输出格式
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.
输入输出样例
输入样例 #1
4
输出样例 #1
3
2 4 3
输入样例 #2
6
输出样例 #2
4
2 4 3 5