← All problemsSign in

Alternating Divisibility

CodeChefRating 1483Open on judge ↗

JJ challenges the Chef to construct an array $A$ of length $N$ such that the following conditions hold: - $A_i$ divides $A_{i + 1}$ when $i$ is odd and $1 \le i \le N - 1$ - $A_i$ does not divide $A_{i + 1}$ when $i$ is even and $1 \le i \le N - 1$ - $1 \le A_i \le 2 \cdot N$ - All $A_i$ are pairwise **distinct** Can you help Chef complete JJ's challenge? If multiple arrays satisfying the above

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start