Bookshelves

题意翻译

## 题意: $Keks$ 先生是 $Byteland$ 大陆的典型的白领。 他办公室里有一个书架,上面有几本书,每本书都有一个值为正整数的价格。 $Keks$ 先生把书架的价值定义为书价的总和。 出乎意料地是, $Keks$ 先生升职了,现在他要去一个新的办公室。 他知道,在新的办公室里,他将有不止一个书架,而恰恰是 $K$ 个书架。 他认为 $K$ 个书架的美丽程度在于所有书架的价值的“按位与”和。 他还决定不花时间重新整理书籍,所以他会先把几本书放在第一个书架上,下几本书放在下一个书架上,以此类推。当然,他会在每一个架子上放置至少一本书。这样,他会把所有的书放在 $K$ 个书架上,尽量使书架的美观程度越大越好。计算这个最大可能的美丽程度。 ## 输入输出格式: ### 输入格式: 两行, 第一行两个数:$n,k$ 书本数,书架数。 第二行 $n$ 个整数,每本书的价值。 ### 输出格式: 一个数,最大可能的美丽程度

题目描述

Mr Keks is a typical white-collar in Byteland. He has a bookshelf in his office with some books on it, each book has an integer positive price. Mr Keks defines the value of a shelf as the sum of books prices on it. Miraculously, Mr Keks was promoted and now he is moving into a new office. He learned that in the new office he will have not a single bookshelf, but exactly $ k $ bookshelves. He decided that the beauty of the $ k $ shelves is the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) of the values of all the shelves. He also decided that he won't spend time on reordering the books, so he will place several first books on the first shelf, several next books on the next shelf and so on. Of course, he will place at least one book on each shelf. This way he will put all his books on $ k $ shelves in such a way that the beauty of the shelves is as large as possible. Compute this maximum possible beauty.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1 \leq k \leq n \leq 50 $ ) — the number of books and the number of shelves in the new office. The second line contains $ n $ integers $ a_1, a_2, \ldots a_n $ , ( $ 0 < a_i < 2^{50} $ ) — the prices of the books in the order they stand on the old shelf.

输出格式


Print the maximum possible beauty of $ k $ shelves in the new office.

输入输出样例

输入样例 #1

10 4
9 14 28 1 7 13 15 29 2 31

输出样例 #1

24

输入样例 #2

7 3
3 14 15 92 65 35 89

输出样例 #2

64

说明

In the first example you can split the books as follows: $ $$$(9 + 14 + 28 + 1 + 7) \& (13 + 15) \& (29 + 2) \& (31) = 24. $ $ </p><p>In the second example you can split the books as follows:</p><p> $ $ (3 + 14 + 15 + 92) \& (65) \& (35 + 89) = 64. $ $$$