Permutations with Coprimes
CodeChefOpen on judge ↗
Find the minimum number of moves, so that the given sequence of integers becomes a perfect sequence. An integer sequence $S$ of length $n$ is said to be a perfect sequence if $S[i]$ and $S[j]$ are co-prime for any $i,j$ (i and j are not-equal) in $[1,n]$. At each move, one can choose an integer $S[i]$ in the sequence and shall replace it with the number 1. ###Input: - The first line of the i
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