Taking Notes | CodeChef

How does xor gives solution here?

Because xor is same as the nim addition of digits 0 and 1!

1 Like

@ks3rr My intuition said to xor it , but I didn’t . FML :frowning:

2 Likes

Have a look at Spargue-Grundy Theorm

2 Likes

xor is fun!

1 Like

Can you tell when will we get the original ranklist ? It has frozen like forever :frowning:

I know its a modification of game of nim… but why xoring it with pile size -1?..
I mean how does it ensure the dividing into two part…
and what if we can divide one pile into k piles…how does it change the solution?

2 Likes

Maybe since 1 pile cannot be broken again…just considering pile size to be pile size -1 in the game of nim does the trick? Is it? And then if we have to break into k piles …answer can be determined by xoring with
pile size -k+1?

1 Like