EPS/04-03-24/d.py
2024-03-15 14:06:32 +01:00

31 lines
613 B
Python

[n, p] = [int(a) for a in input().split()]
aset = set([int(a) for a in input().split()])
for a in aset.copy():
initial_a = a
while a > 0:
if a%2 == 1:
a = (a-1)//2
elif a%4 == 0:
a = a//4
else:
break
if a in aset:
aset.discard(initial_a)
break
t={i:0 for i in range(p+2)}
n=0
modval = (10**9 +7)
for e in aset:
i=e.bit_length()-1 # Log2 plus efficace
if i<p:
t[i]+=1
for i in range(p):
t[i+1] = (t[i]+t[i+1])%modval
t[i+2] = (t[i]+t[i+2])%modval
n=(t[i]+n)%modval
print(n%modval)