#P6245. 【贪心】[ONTAK2015] OR-XOR

【贪心】[ONTAK2015] OR-XOR

P8019 [ONTAK2015] OR-XOR

题目描述

给定一个长度为 nn 的序列 a1,a2,,ana_1, a_2, \cdots, a_n,请将它划分为 mm 段连续的区间,设第 ii 段的费用 cic_i 为该段内所有数字的异或和,则总费用为 $c_1 \operatorname{or} c_2 \operatorname{or} \cdots \operatorname{or} c_m$。请求出总费用的最小值。

输入格式

第一行,两个整数 n,mn, m

第二行,nn 个整数 a1,a2,,ana_1, a_2, \cdots, a_n

输出格式

一行,一个整数,表示所求的值。

输入输出样例 #1

输入 #1

3 2
1 5 7

输出 #1

3

说明/提示

对于 100%100\% 的数据,1mn5×1051 \leq m \leq n \leq 5 \times 10^50ai10180 \leq a_i \leq 10^{18}