← All problemsSign in

Niceness of the Arrays

CodeChefRating 2618Open on judge ↗

Let's define the *niceness* of a sequence of positive integers $X_1, X_2, \dots, X_N$ as the sum of greatest common divisors of all pairs of its elements, i.e. $$\sum_{i=1}^N \sum_{j=i+1}^N \mathrm{gcd}(X_i, X_j)\;.$$ For example, the niceness of the sequence $[1, 2, 2]$ is $gcd(1, 2) + gcd(1, 2) + gcd(2, 2) = 4$. You are given a sequence $A_1, A_2, \dots, A_N$; each of its elements is eith

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