← All problemsSign in

Expected Greatest Common Divisor

CodeChefRating 2471Open on judge ↗

Several integers X0, X1, ..., XK-1 are randomly chosen from some intervals. Namely, X0 is randomly chosen between A0 and B0, inclusive, X1 is randomly chosen between A1 and B1, inclusive, and so on. We are interested in the expected value of the greatest common divisor of the Xi which is the average of GCD(X0, X1, ..., XK-1) over all possible choices of X0, X1, ..., XK-1. In order to avoid floatin

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