A15891 | Don't Blame Me
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Sadly, the problem setter couldn't think of an interesting story, thus he just asks you to solve the following problem.
Given an array $a$ consisting of $n$ positive integers, count the number of non-empty subsequences for which the bitwise $\mathsf{AND}$ of the elements in the subsequence has exactly $k$ set bits in its binary representation. The answer may be large, so output it modulo $10^9+7$ .
Recall that the subsequence of an array $a$ is a sequence that can be obtained from $a$ by removing some (possibly, zero) elements. For example, $[1, 2, 3]$ , $[3]$ , $[1, 3]$ are subsequences of $[1, 2, 3]$ , but $[3, 2]$ and $[4, 5, 6]$ are not.
Note that $\mathsf{AND}$ represents the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
Given an array $a$ consisting of $n$ positive integers, count the number of non-empty subsequences for which the bitwise $\mathsf{AND}$ of the elements in the subsequence has exactly $k$ set bits in its binary representation. The answer may be large, so output it modulo $10^9+7$ .
Recall that the subsequence of an array $a$ is a sequence that can be obtained from $a$ by removing some (possibly, zero) elements. For example, $[1, 2, 3]$ , $[3]$ , $[1, 3]$ are subsequences of $[1, 2, 3]$ , but $[3, 2]$ and $[4, 5, 6]$ are not.
Note that $\mathsf{AND}$ represents the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 10^4$ ). The description of the test cases follows.
The first line of each test case consists of two integers $n$ and $k$ ( $1 \leq n \leq 2 \cdot 10^5$ , $0 \le k \le 6$ ) — the length of the array and the number of set bits that the bitwise $\mathsf{AND}$ the counted subsequences should have in their binary representation.
The second line of each test case consists of $n$ integers $a_i$ ( $0 \leq a_i \leq 63$ ) — the array $a$ .
It is guaranteed that the sum of $n$ over all test cases doesn't exceed $2 \cdot 10^5$ .
The first line of each test case consists of two integers $n$ and $k$ ( $1 \leq n \leq 2 \cdot 10^5$ , $0 \le k \le 6$ ) — the length of the array and the number of set bits that the bitwise $\mathsf{AND}$ the counted subsequences should have in their binary representation.
The second line of each test case consists of $n$ integers $a_i$ ( $0 \leq a_i \leq 63$ ) — the array $a$ .
It is guaranteed that the sum of $n$ over all test cases doesn't exceed $2 \cdot 10^5$ .
输出格式
For each test case, output a single integer — the number of subsequences that have exactly $k$ set bits in their bitwise $\mathsf{AND}$ value's binary representation. The answer may be large, so output it modulo $10^9+7$ .
输入输出样例
输入 #1
6 5 1 1 1 1 1 1 4 0 0 1 2 3 5 1 5 5 7 4 2 1 2 3 12 0 0 2 0 2 0 2 0 2 0 2 0 2 10 6 63 0 63 5 5 63 63 4 12 13
输出 #1
31 10 10 1 4032 15
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted