Codeforces Round 195 (Div. 2)
C
Vasily the Bear and Sequence
Codeforces
1800
原题
← BD →
翻译中…

Vasily the bear has got a sequence of positive integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum.

翻译中…

The beauty of the written out numbers $*b*_{1}, *b*_{2}, ..., *b*_{*k*}$ is such maximum non-negative integer $*v*$, that number $*b*_{1}$ $*and*$ $*b*_{2}$ $*and*$ $...$ $*and*$ $*b*_{*k*}$ is divisible by number $2^{*v*}$ without a remainder. If such number $*v*$ doesn't exist (that is, for any non-negative integer $*v*$, number $*b*_{1}$ $*and*$ $*b*_{2}$ $*and*$ $...$ $*and*$ $*b*_{*k*}$ is divisible by $2^{*v*}$ without a remainder), the beauty of the written out numbers equals -1.

翻译中…

Tell the bear which numbers he should write out so that the beauty of the written out numbers is maximum. If there are multiple ways to write out the numbers, you need to choose the one where the bear writes out as many numbers as possible.

翻译中…

Here expression $*x*$ $*and*$ $*y*$ means applying the bitwise AND operation to numbers $*x*$ and $*y*$. In programming languages C++ and Java this operation is represented by "&", in Pascal — by "and".

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$). The second line contains $*n*$ space-separated integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ $(1 ≤ *a*_{1} < *a*_{2} < ... < *a*_{*n*} ≤ 10^{9})$.

翻译中…

Output

翻译中…

In the first line print a single integer $*k*$ $(*k* > 0)$, showing how many numbers to write out. In the second line print $*k*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*k*}$ — the numbers to write out. You are allowed to print numbers $*b*_{1}, *b*_{2}, ..., *b*_{*k*}$ in any order, but all of them must be distinct. If there are multiple ways to write out the numbers, choose the one with the maximum number of numbers to write out. If there still are multiple ways, you are allowed to print any of them.

翻译中…

样例

Input #1
5
1 2 3 4 5
Output #1
2
4 5
InputCopy OutputCopy
Input #2
3
1 2 4
Output #2
1
4
InputCopy OutputCopy
题目信息
题号
336C
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
模拟
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。