P5179 Fraction
Description
You are given four positive integers $a,\,b,\,c,\,d$. Find a fraction $\frac{p}{q}$ in lowest terms such that $\frac{a}{b} < \frac{p}{q} < \frac{c}{d}$.
If there are multiple solutions, output the one with the smallest $q$. If there are still multiple solutions, output the one with the smallest $p$.
Input Format
This problem contains multiple test cases. There are several lines, and each line contains four positive integers, which are $a,b,c,d$ for one test case.
Output Format
For each test case, output one line. If the answer is $\frac{p}{q}$, print it in the format `p/q`.
Explanation/Hint
|Test Point ID|Number of Test Cases|Constraints on $a,b,c,d$|
|:-:|:-:|:-:|
|$1 \sim 3$|$\leqslant 100$|$\leqslant 100$|
|$4 \sim 10$|$\leqslant 500$|$\leqslant 10^9$|
The testdata guarantees that there exists at least one fraction in lowest terms that satisfies the condition.
Translated by ChatGPT 5