[Codeforces R489D2C] Nastya and a Wardrobe

手模一下发现除掉最后一轮会形成一个区间

那么

L=\left( \left( \left( x\times 2 \right) -1 \right) \times 2-1 \right) \times 2-1\cdots =x\cdot 2^k-2^{k-1}-2^{k-2}\cdots -1 L=x\cdot 2^k-2^k+\text{1 } R=x\cdot 2^k \text{ans}=\frac{S\left( L,R \right) \times 2}{2^k} =\frac{\frac{\left( R-L+1 \right) \left( R+L \right)}{2}\times 2}{2^k} =\frac{2^k\cdot \left( x\cdot 2^{k+1}-2^k+1 \right)}{2^k} =x\cdot 2^{k+1}-2^k+1

然后暴算这个东西。