luogu#P5179. Fraction
Fraction
Problem Description
You are given four positive integers . Find a fraction in lowest terms such that .
If there are multiple solutions, output the one with the smallest . If there are still multiple solutions, output the one with the smallest .
Input Format
This problem contains multiple test cases. There are several lines, and each line contains four positive integers, which are for one test case.
Output Format
For each test case, output one line. If the answer is , print it in the format p/q.
1 3 1 2
2 1 3 1
2 1 4 1
1000 1001 1001 1002
2/5
5/2
3/1
2001/2003
Hint
| Test Point ID | Number of Test Cases | Constraints on |
|---|---|---|
The testdata guarantees that there exists at least one fraction in lowest terms that satisfies the condition.
Translated by ChatGPT 5