CF1635D.Infinite Set

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of nn distinct positive integers.

Let's consider an infinite integer set SS which contains all integers xx that satisfy at least one of the following conditions:

  1. x=aix = a_i for some 1≤i≤n1 \leq i \leq n.
  2. x=2y+1x = 2y + 1 and yy is in SS.
  3. x=4yx = 4y and yy is in SS.

For example, if a=[1,2]a = [1,2] then the 1010 smallest elements in SS will be 1,2,3,4,5,7,8,9,11,12{1,2,3,4,5,7,8,9,11,12}.

Find the number of elements in SS that are strictly smaller than 2p2^p. Since this number may be too large, print it modulo 109+710^9 + 7.

给你一个由 nn 个互不相同的正整数组成的数组 aa。

考虑一个无限整数集合 SS,它包含所有满足以下至少一个条件的整数 xx:

  1. x=aix = a_i,其中 1≤i≤n1 \leq i \leq n;
  2. x=2y+1x = 2y + 1,且 y∈Sy \in S;
  3. x=4yx = 4y,且 y∈Sy \in S。

例如,若 a=[1,2]a = [1,2],则 SS 中最小的 1010 个元素为 {1,2,3,4,5,7,8,9,11,12}\{1,2,3,4,5,7,8,9,11,12\}。

求 SS 中严格小于 2p2^p 的元素个数。由于该数可能过大,请输出其对 109+710^9 + 7 取模的结果。

输入格式

The first line contains two integers nn and pp (1≤n,p≤2⋅105)(1 \leq n, p \leq 2 \cdot 10^5).

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n (1≤ai≤109)(1 \leq a_i \leq 10^9).

It is guaranteed that all the numbers in aa are distinct.

第一行包含两个整数 nn 和 pp (1≤n,p≤2⋅105)(1 \leq n, p \leq 2 \cdot 10^5)。

第二行包含 nn 个整数 a1,a2,…,ana_1,a_2,\ldots,a_n (1≤ai≤109)(1 \leq a_i \leq 10^9)。

保证数组 aa 中的所有数互不相同。

输出格式

Print a single integer, the number of elements in SS that are strictly smaller than 2p2^p. Remember to print it modulo 109+710^9 + 7.

输出一个整数,表示集合 SS 中严格小于 2p2^p 的元素个数。注意:结果需对 109+710^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 242^4 are 1,3,4,6,7,9,12,13,15{1, 3, 4, 6, 7, 9, 12, 13, 15}.

In the second example, the elements smaller than 272^7 are 5,11,20,23,39,41,44,47,79,80,83,89,92,95{5,11,20,23,39,41,44,47,79,80,83,89,92,95}.

在第一个例子中,小于 242^4 的元素为 1,3,4,6,7,9,12,13,15{1, 3, 4, 6, 7, 9, 12, 13, 15}。

在第二个例子中,小于 272^7 的元素为 5,11,20,23,39,41,44,47,79,80,83,89,92,95{5,11,20,23,39,41,44,47,79,80,83,89,92,95}。

输入解题思路,AI测评打分。不知道怎么写?

首页