Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- m = 1000000000+7
- n,c=list(map(int,input().strip().split()))
- p={}
- f=0
- s=set()
- for i in range(n):
- k=str(bin(int((input()))))[2:]
- r=len(k)
- if r not in s:
- p[r]=[]
- s.add(r)
- p[r]+=[k]
- while len(s)>0:
- q=max(s)
- w=p[q]
- if len(w)<c:
- for i in w:
- for j in range (1,q):
- if i[j]=='1':
- r=q-j
- if r>=0:
- if r not in s:
- s.add(r)
- p[r]=[]
- p[r]+=[i[j:]]
- break
- else:
- for i in range (q):
- p=[]
- for j in w:
- if j[i]=='1':
- p+=[j]
- if len(p)>=c:
- w=p
- f=int(w[1],2)
- for i in w:
- f=f&int(i,2)
- k=len(w)
- g= (((math.factorial(k))%m)/(((math.factorial(c)%m)*(math.factorial(k-c))%m)))%m
- print(f)
- print(int(g))
- break
- s.discard(q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement