#P4144. 大河的序列

大河的序列

题目背景

“唯有龙虎相伴 最是脉脉深情。”

题目来源:KingSann

题目描述

大河有一些袜子,但经常十分散乱的堆放着。有一天龙儿忍不住了,于是将袜子放到了一个序列上(称作袜子序列)。

每个袜子都有一个 dirty\text{dirty} 值,定义袜子序列的 dirty\text{dirty} 值为

$$\max [(\text{dirty}_{l}\ \& \ \text{dirty}_{l+1}\ \& \ \cdots \ \& \ \text{dirty}_{r}) + (\text{dirty}_{l} \ | \ \text{dirty}_{l+1} \ | \ \cdots \ | \ \text{dirty}_{r}) ]$$

其中 dirtyi \text{dirty}_{i} 表示第 i i 只袜子的 dirty \text{dirty} 值,&\& 表示按位与,| 表示按位或。

简而言之,就是找一段连续子序列,使得所有数字的按位与加上按位或最大。

如果这个袜子序列的 dirty\text{dirty} 值达到了某个阈值,那么龙儿会讨厌大河的。大河当然不希望这样了,于是她想知道这个袜子序列的 dirty\text{dirty} 值是多少。

输入格式

第一行三个整数 n,b,p n,b,p ,其中 nn 表示数列长度,b,pb,p 与输出格式有关。

第二行有 n n 个整数,表示这个数列的初始数值。

输出格式

设答案为 x x ,你需要输出 (x+233)bmodp (x+233)^{b}\bmod p

10 1 10000000
7 9 9 4 0 0 8 8 4 7
251

提示

1n,p105 1 \le n, p \le 10^{5} 0b,dirtyi107 0 \le b, \text{dirty}_{i} \le 10^{7}

对于测试点 1 1 和测试点 2 2 的数据,保证 1n100 1 \le n \le 100