Counting Pairs
Given an integer $N$, find the number of tuples $(w, x, y, z)$ such that $1 \leq w, x, y, z \leq N$ and $\frac{w}{x} + \frac{y}{z}$ is an integer. For example, if $N = 2$, the tuple $(1,2,1,2)$ satisfies both conditions, i.e. $\frac{1}{2} + \frac{1}{2} = 1$ is an integer, however $(1,1,1,2)$ does not since $\frac{1}{1} + \frac{1}{2} = 1.5$ is not an integer. ### Input - The first line of input c
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