Comments

The proofs of A and B are amazing.

OMG, that's such a nice proof, thank you!!

I know a DSU solution works. My question is specifically about the proof in the editorial. I'm curious why the condition $$$x + y \le n$$$ guarantees that we can always move from $$$i$$$ to $$$i \pm \gcd(x, y)$$$ without leaving the array.

Can someone provide a proof of why the condition $$$x + y \le n$$$ is sufficient?

Nice B

You call this a classic div 4 problem make me think a way to solve without fenwick tree and finally the editorial jumps straight to PBDS:))