← All problemsSign in

Chef And Partytions

CodeChefRating 3058Open on judge ↗

Chef is hosting a party. There are $2N$ people in this party (excluding Chef). Each person has a unique ID $i$ which ranges from $1$ to $2N$. Chef wants to make $N$ pairs of the $2N$ people (that is, each pair should contain $2$ people). A pair of people $(i,j)$ will be sad if $\gcd(i,j)=1$. Chef wants to minimize the number of sad pairs. Can you help him find the minimum number of sad pairs and

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