NAJGC - Game of chocolate

no tags 

Ben and Gwen gets two bag of chocolate from grandpa. Ben’s bag contain X1 kit-Kat and Y1 Park chocolate. Gwen’s bag contain X2 kit-Kat and Y2 Park. But Ben don’t like chocolate, so he decided to give all the chocolate to Gwen. But he want to play a game with Gwen. The game is very simple, and if Gwen win the game he will give all the chocolate to Gwen. The game follow those rules:

  1. First Ben take a chocolate from his bag and it will be unknown to Gwen.
  2. Then he placed the chocolate to Gwen bag.
  3. Then Gwen take a chocolate form her bag.
  4. If Gwen take chocolate is same as Ben chocolate then she win the game and get all the chocolate from Ben.

Now, Find out the probability of Gwen win in the game.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each line contain four integer x1, y1, x2, y2 which denotes ben chocolate and Gwen chocolate respectively. Where 0 ≤ x1, y1, x2, y2 ≤ 1000000

Output

For each test case print the case number and Gwen win probability in a/b format, where a/b is irreducible fraction. If in any test case probability is zero, just print ‘0’ (Case x: 0).

Sample

Input
2
3 5 4 5
1 3 4 8
Output
Case 1: 9/16
Case 2: 8/13
 

Authored By: Tanvir Hasan Anick


hide comments
SHASHANK PAL: 2014-11-04 15:26:53

My 100th AC solution :D

fitcat: 2014-11-02 11:23:28

My AC solution assumed x1, y1, x2 and y2 are all within signed 32-bit integers. Note that for probability 1, output 1/1.

Jacob Plachta: 2014-11-01 03:41:30

Apparently Ben can have zero chocolates (X1=Y1=0), though this doesn't make sense with Step 1. However, the answer for such a case is 0.

Ans -> (Najmuzzaman) That may be happen. If Ben’s bag contain X1=0 kit-Kat and Y1=0 Park chocolate. and first step Ben take a chocolate from his bag (it must be 0 if the bag is empty).

Last edit: 2014-11-04 18:34:27

Added by:Najmuzzaman
Date:2014-10-31
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64