当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5637:Transform

题目描述
A list of $n$ integers are given. For an integer $x$ you can do the following operations:

+ let the binary representation of $x$ be $\overline{b_{31}b_{30}...b_0}$, you can flip one of the bits.
+ let $y$ be an integer in the list, you can change $x$ to $x \oplus y$, where $\oplus$ means bitwise exclusive or operation.

There are several integer pairs $(S, T)$. For each pair, you need to answer the minimum operations needed to change $S$ to $T$.
输入解释
There are multiple test cases. The first line of input contains an integer $T$ $(T \le 20)$, indicating the number of test cases. For each test case:

The first line contains two integer $n$ and $m$ $(1 \le n \le 15, 1 \le m \le 10^5)$ -- the number of integers given and the number of queries. The next line contains $n$ integers $a_1, a_2, ..., a_n$ $(1 \le a_i \le 10^5)$, separated by a space.

In the next $m$ lines, each contains two integers $s_i$ and $t_i$ $(1 \le s_i, t_i \le 10^5)$, denoting a query.
输出解释
For each test cases, output an integer $S=(\displaystyle\sum_{i=1}^{m} i \cdot z_i) \text{ mod } (10^9 + 7)$, where $z_i$ is the answer for $i$-th query.
输入样例
1
3 3
1 2 3
3 4
1 2
3 9
输出样例
10
提示
$3 \to 4$ (2 operations): $3 \to 7 \to 4$

$1 \to 2$ (1 operation): $1 \oplus 3 = 2$

$3 \to 9$ (2 operations): $3 \to 1 \to 9$
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5637

最后修改于 2020-10-25T23:24:24+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 131072/131072K(Java/Others)