Valid Genesis Sequence
CodeChefOpen on judge ↗
A sequence of positive integers $x_1$,$x_2$,…,$x_n$ is valid genesis sequence if for all $i$ from $1$ to n−1 all ones (of binary representation) in $x_i$ are in the places of ones (of binary representation) in $x_i+_1$ (in other words, $x_i$&$x_i+_1$=$x_i$, where & denotes bitwise AND). If n=1 then the sequence is considered valid as well. For example, the following sequences are valid: [$5$,$1
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start