← All problemsSign in

A Short Counting Problem

CodeChefRating 2438Open on judge ↗

Given two integers $A$ and $B$, find the count of integers $X \in [L, R]$ such that **at least** one of the following is true: - $X$ and $A$ are [coprime](https://en.wikipedia.org/wiki/Coprime_integers) - $X$ and $B$ are [coprime](https://en.wikipedia.org/wiki/Coprime_integers) ### Input - The first and only line of input contains four integers $A,B,L,$ and $R$: as given in the problem statement.

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