P4144 大河的序列

题目背景

“唯有龙虎相伴 最是脉脉深情。” 题目来源:[KingSann](https://www.luogu.org/space/show?uid=47111)。

题目描述

大河有一些袜子,但经常十分散乱的堆放着。有一天龙儿忍不住了,于是将袜子放到了一个序列上(称作袜子序列)。 每个袜子都有一个 $\text{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}) ]$$ 其中 $ \text{dirty}_{i} $ 表示第 $ i $ 只袜子的 $ \text{dirty} $ 值,$\&$ 表示按位与,$|$ 表示按位或。 简而言之,就是找一段连续子序列,使得所有数字的按位与加上按位或最大。 如果这个袜子序列的 $\text{dirty}$ 值达到了某个阈值,那么龙儿会讨厌大河的。大河当然不希望这样了,于是她想知道这个袜子序列的 $\text{dirty}$ 值是多少。

输入格式

第一行三个整数 $ n,b,p $,其中 $n$ 表示数列长度,$b,p$ 与输出格式有关。 第二行有 $ n $ 个整数,表示这个数列的初始数值。

输出格式

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

说明/提示

$ 1 \le n, p \le 10^{5} $,$ 0 \le b, \text{dirty}_{i} \le 10^{7} $。 对于测试点 $ 1 $ 和测试点 $ 2 $ 的数据,保证 $ 1 \le n \le 100 $。