Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import combinations
- x=raw_input()
- y=x.split()
- N=int(y[0])
- K=int(y[1])
- z=raw_input()
- Arr=z.split()
- Main=[]
- for i in Arr:
- Main.append(int(i))
- combs=combinations(Main,K)
- shortcombs=set(combs)
- def xor(L):
- S=0
- for i in L:
- S=xor_of_nums(S,i)
- return S
- def xor_of_nums(x,y):
- ans=0;
- i=0;
- while(x>0 or y>0):
- ans=ans+((x%10+y%10)%10)*(10**i)
- x=x/10
- y=y/10
- i=i+1
- return ans
- max=0
- for i in shortcombs:
- ans=xor(i)
- if(ans>max):
- max=ans
- if(ans==9):
- break
- print(max)
Add Comment
Please, Sign In to add comment