Submit solution
Points:
0.90 (partial)
Time limit:
4.5s
Memory limit:
512M
Input:
stdin
Output:
stdout
Problem source:
Problem type
Allowed languages
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given ~a,b,c,d~ find a fraction ~\frac{p}{q}~ with minimum ~q~, and satisfied ~\frac{a}{b}~ ~<~ ~\frac{p}{q}~ ~<~ ~\frac{c}{d}~ .
Input
For each test case, one line contains four integers a,b,c,d .
Dataset 1: ~a,b,c,d~ ( 1 ~\le~ ~a,b,c,d~ ~\le~ ~1e9~, and ~\frac{a}{b}~ ~<~ ~\frac{c}{d}~ )
Output
- For each test case, print the fraction(see the sample for details).If multiple solution exists, output the one with minimum ~p~.
Sample Input
1 3 1 2
2 1 3 1
2 1 4 1
1000 1001 1001 1002
Sample Output
2/5
5/2
3/1
2001/2003
Comments
e thắc mắc chuyện này, nếu a/b < p/q < c/d thì tại sao kq lại dương hết vậy (nếu p/q thỏa thì -p/-q cũng thỏa)
Đề viết thiếu, in ra kq có p q > 0 thôi, nếu ko thì minimum p là âm vô cùng.