Help in NUMGAME2

I just read the editorial for this problem and i was wondering that how do you tackle these kind of problems.

Why Alice wins when n%4 == 1 and bob wins for other cases ?