Comments

Oh, I got it! Thanks!

Can someone give a hint for problem E?

Edit: Nvm I outputted x+1 instead of x.

For problem D, wouldn't $$$x \mod {2^{k + 1}} = r + 2^k$$$ if the gcd is equal to $$$2^{k + 1}$$$? (not k — 1 as written)?

My reasoning is as follows: let $$$x = y\cdot 2^k + r$$$. Thus, the gcd becomes $$$\gcd((y + 1)\cdot 2^k, (y + 3)\cdot 2^k)$$$. If the gcd is $$$2^{k + 1}$$$, that means $$$y$$$ is odd. Thus $$$x = (y - 1)\cdot 2^k + 2^k + r$$$. Since $$$y - 1$$$ is even, $$$(y-1)\cdot2^k$$$ can be written as a multiple of $$$2^{k + 1},$$$ making $$$x \equiv 2^k + r \pmod {2^{k + 1}}.$$$