paraschhabra96

last q

Sep 3rd, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. from itertools import combinations
  2.  
  3. x=raw_input()
  4. y=x.split()
  5. N=int(y[0])
  6. K=int(y[1])
  7.  
  8. z=raw_input()
  9. Arr=z.split()
  10. Main=[]
  11. for i in Arr:
  12. Main.append(int(i))
  13.  
  14. combs=combinations(Main,K)
  15. shortcombs=set(combs)
  16.  
  17. def xor(L):
  18. S=0
  19. for i in L:
  20. S=xor_of_nums(S,i)
  21.  
  22. return S
  23.  
  24. def xor_of_nums(x,y):
  25. ans=0;
  26. i=0;
  27. while(x>0 or y>0):
  28. ans=ans+((x%10+y%10)%10)*(10**i)
  29. x=x/10
  30. y=y/10
  31. i=i+1
  32. return ans
  33.  
  34. max=0
  35. for i in shortcombs:
  36. ans=xor(i)
  37. if(ans>max):
  38. max=ans
  39. if(ans==9):
  40. break
  41.  
  42. print(max)
Add Comment
Please, Sign In to add comment