Infinite Set solution codeforces
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:
- x=aix=ai for some 1≤i≤n1≤i≤n.
- x=2y+1x=2y+1 and yy is in SS.
- 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 2p2p. Since this number may be too large, print it modulo 109+7109+7.
The first line contains two integers nn and pp (1≤n,p≤2⋅105)(1≤n,p≤2⋅105).
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤109)(1≤ai≤109).
It is guaranteed that all the numbers in aa are distinct.
Print a single integer, the number of elements in SS that are strictly smaller than 2p2p. Remember to print it modulo 109+7109+7.
2 4 6 1
9
4 7 20 39 5 200
14
2 200000 48763 1000000000
448201910
In the first example, the elements smaller than 2424 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 2727 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}.
-
For Solution
Click Here!