An AND problem-j9国际集团直营

1508: An AND problem

时间限制: 1000 ms  内存限制: 128 MB
提交: 21  解决: 7
[提交][状态][讨论版]

题目描述

You are given an array a of n integers and a positive integer k, you need to pick any number of k from the n Numbers, maximize their AND(&) value x, output the maximum value of x, and the k Numbers that you choose.

输入


The first line contains two integers n(1≤n≤100000), k(1≤k≤n), separated by a space.
The second line contains n elements of an array a separated by spaces: a1,a2,…,an (0≤ai≤1000000000).

输出

The output should contain two lines.
The first line contain an integer x, as described above.
The second line contains k positive integers, separated by Spaces, representing the k Numbers of your choice.No extra space at the end of the line.
If you have more than one solution, output the solution in lexicographic order.
Lexicographical order is defined in following way. When we compare sequence A and sequence B, if there is a position j, such that for any i from 1 to j-1 , ai==bi and aj<bj, then we assume that the lexicographic order of sequence A is less than that of sequence B.

样例输入

4 2
3 7 9 16

样例输出

3
3 7

提示

来源

[提交][状态][讨论版]