Finding Fractions


Submit solution

Points: 0.90 (partial)
Time limit: 4.5s
Memory limit: 512M

Problem source:
Code Craft 09
Problem type

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


  • 2
    LeMinhDuc  commented on 8, Jun, 2021, 20:08

    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)


    • 1
      I_love_Hoang_Yen  commented on 8, Jun, 2021, 20:16

      Đề viết thiếu, in ra kq có p q > 0 thôi, nếu ko thì minimum p là âm vô cùng.