FINFRAC - Finding Fractions

no tags 

Given a,b,c,d, find a fraction p/q with minimum q, and satisfied a/b < p/q < c/d .

Input

For each test case, one line contains four integers a,b,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.

Example

Input:
1 3 1 2
2 1 3 1
2 1 4 1
1000 1001 1001 1002

Output:
2/5
5/2
3/1
2001/2003

Constraints

Dataset 1: a,b,c,d ( 1 <= a,b,c,d <= 1e9, and a/b < c/d )


hide comments
prad_131: 2016-08-17 19:48:29

Last edit: 2017-06-27 14:44:34
numerix: 2015-02-20 16:39:04

It seems that testdata has been changed in the last days and a rejudge has taken place (?). All my (even years old) AC submissions show NZEC over night.
As the problemsetter seems inactive for the last two years, I really would like to know what happend here.

(Francky) => I send you an email with last info from admin for this problem. There are new data, and a rejudge have been made by admin. A comment could have been set here. Now we can consider it's done.

Last edit: 2015-02-20 16:52:11
Bhavik: 2015-02-16 02:15:53

learnt a new concept:)

Simes: 2015-02-16 02:15:53

@nitish rao:
(1+3)/(2+4) = 4/6 = 2/3

@nblt:
try
1 100 4 5
answer is 1/2

Last edit: 2013-11-28 21:05:47
nitish rao: 2015-02-16 02:15:53

@nbit: for 1/2 and 3/4 is the answer (1+3)/(2+4) = 1/2 ?? hence its wrong..

nblt: 2015-02-16 02:15:53

I have an idea:
a/b<(a+c)/(b+d)<c/d
but I get wrong answer.Why?

Last edit: 2013-04-02 07:45:21
Ashutosh: 2015-02-16 02:15:53

time exceeding!!
any1 2 help with clue!! :P

Last edit: 2011-04-21 10:17:27
Anant Sharma: 2015-02-16 02:15:53

Is the input ever supposed to end or not? :P


Added by:Race with time
Date:2009-02-19
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Code Craft 09