Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import math
  2. m = 1000000000+7
  3. n,c=list(map(int,input().strip().split()))
  4. p={}
  5. f=0
  6. s=set()
  7. for i in range(n):
  8. k=str(bin(int((input()))))[2:]
  9. r=len(k)
  10. if r not in s:
  11. p[r]=[]
  12. s.add(r)
  13. p[r]+=[k]
  14. while len(s)>0:
  15. q=max(s)
  16. w=p[q]
  17. if len(w)<c:
  18. for i in w:
  19. for j in range (1,q):
  20. if i[j]=='1':
  21. r=q-j
  22. if r>=0:
  23. if r not in s:
  24. s.add(r)
  25. p[r]=[]
  26. p[r]+=[i[j:]]
  27. break
  28. else:
  29. for i in range (q):
  30. p=[]
  31. for j in w:
  32. if j[i]=='1':
  33. p+=[j]
  34. if len(p)>=c:
  35. w=p
  36. f=int(w[1],2)
  37. for i in w:
  38. f=f&int(i,2)
  39. k=len(w)
  40. g= (((math.factorial(k))%m)/(((math.factorial(c)%m)*(math.factorial(k-c))%m)))%m
  41. print(f)
  42. print(int(g))
  43.  
  44. break
  45. s.discard(q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement