Hint-1
- Is there any distinguishing feature that makes one positive integer different from other?
Hint-2
- Can we replace all positive integers with a particular number, say
$p$ and all negative integers with a number, say$n$ and in the final state of array we can just count the number of$p$ .
Hint-3
-
Exactly one positive neighbour can make
$A_i$ positive. Does this strike any bitwise operation in your mind.
Tutorial
The word integer sequence and array mean the same thing throughout this tutorial.
We can choose
If
Hint-2 proof
-
We see that both the operation only change sign on
$A_i$ but the magnitude remains intact. Does changing magnitude of$A_i$ will have no effect. Here, magnitude of$x = | x | $
Let us denote state of array after
For any
In fact we can generalise it by saying,
Follow up Question
- Can you prove why this would not be the case if
$K$ is not a power of$2$ ? - For Example,
$C_{3, \ i} \neq C_{0, \ i - 3} \oplus C_{0, \ i - 3}$
The next step is how do we generalise it for any
Example-1: If
Example-2: For
- Generate
$C_2$ from$C_0$ - Generate
$C_{2 + 4}$ from$C_2$ - Generate
$C_{6 + 8}$ from$C_6$
Since number of bits in a number