Problem A.

This problem is solved by simple emulation. After 2

*n*jumps flea returns to initial position, because 1 + 2 + 3 + ... + 2*n*=*n*(2*n*+ 1) is divisible by n. Moreover, after that, jumps would be the same as in the beginning, because 2*n*is divisible by*n*. So it is just enough to emulate first 2*n*jumps.In fact one may see that it is enough to emulate first

*n*jumps and moreover answer is "YES" exactly when*n*is power of two. Last gives alternative solution. For example: printf("%s", n&(n-1) : "NO" ? "YES");
nbe a power of two:n= 2^{m}. Let us prove that firstn- 1 jumps will end at different hassocks. Really, jump with numberkends at hassock . Suppose that jumpsk_{1}andk_{2}ends at the same hassock. It means that . So we get thatk_{1}^{2}+k_{1}-k_{2}^{2}-k_{2}= (k_{1}-k_{2})(k_{1}+k_{2}+ 1) is divisible by 2^{m + 1}. Butk_{1}-k_{2}andk_{1}+k_{2}+ 1 have different parity and both less than 2^{m + 1}. A contradiction. So we derive that all hassocks will be visited after firstn- 1 jumps.If

nisn't a power of two, thennis divisible by some odd primep. Let's look at hassocks not modn, but modp. We will see that not all residues (modp) will be visited. Indeed afterpjumps flea returns to initial residue modp, because is divisible byp. And after that jumps would be the same as in the beginning (modp), becausepis divisible byp. Moreover, even afterp- 1 jumps flea returns to initial residue modp. So there arep- 1 different residues as maximum. Thus not all hassocks will be visited.How is it enough to emulate only first n jumps ???