A14769 | Infinite Set
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an array $a$ consisting of $n$ distinct positive integers.
Let's consider an infinite integer set $S$ which contains all integers $x$ that satisfy at least one of the following conditions:
1. $x = a_i$ for some $1 \leq i \leq n$ .
2. $x = 2y + 1$ and $y$ is in $S$ .
3. $x = 4y$ and $y$ is in $S$ .
For example, if $a = [1,2]$ then the $10$ smallest elements in $S$ will be $\{1,2,3,4,5,7,8,9,11,12\}$ .
Find the number of elements in $S$ that are strictly smaller than $2^p$ . Since this number may be too large, print it modulo $10^9 + 7$ .
Let's consider an infinite integer set $S$ which contains all integers $x$ that satisfy at least one of the following conditions:
1. $x = a_i$ for some $1 \leq i \leq n$ .
2. $x = 2y + 1$ and $y$ is in $S$ .
3. $x = 4y$ and $y$ is in $S$ .
For example, if $a = [1,2]$ then the $10$ smallest elements in $S$ will be $\{1,2,3,4,5,7,8,9,11,12\}$ .
Find the number of elements in $S$ that are strictly smaller than $2^p$ . Since this number may be too large, print it modulo $10^9 + 7$ .
输入格式
The first line contains two integers $n$ and $p$ $(1 \leq n, p \leq 2 \cdot 10^5)$ .
The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ $(1 \leq a_i \leq 10^9)$ .
It is guaranteed that all the numbers in $a$ are distinct.
The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ $(1 \leq a_i \leq 10^9)$ .
It is guaranteed that all the numbers in $a$ are distinct.
输出格式
Print a single integer, the number of elements in $S$ that are strictly smaller than $2^p$ . Remember to print it modulo $10^9 + 7$ .
输入输出样例
输入 #1
2 4 6 1
输出 #1
9
输入 #2
4 7 20 39 5 200
输出 #2
14
输入 #3
2 200000 48763 1000000000
输出 #3
448201910
In the first example, the elements smaller than $2^4$ are $\{1, 3, 4, 6, 7, 9, 12, 13, 15\}$ .
In the second example, the elements smaller than $2^7$ are $\{5,11,20,23,39,41,44,47,79,80,83,89,92,95\}$ .
In the second example, the elements smaller than $2^7$ are $\{5,11,20,23,39,41,44,47,79,80,83,89,92,95\}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted