NAJGC - Game of chocolate
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:
- First Ben take a chocolate from his bag and it will be unknown to Gwen.
- Then he placed the chocolate to Gwen bag.
- Then Gwen take a chocolate form her bag.
- 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 |
Output |
Authored By: Tanvir Hasan Anick
hide comments
Dhruv k14:
2015-04-03 23:00:32
AC with long long int in C,2 WA due to printing error, hehehe easy one to score 0.2 points from :P |
|
Shubham Bansal:
2015-03-28 11:31:29
got 4 WA's because of format only.. phew..!
|
|
MathiasSM:
2015-03-27 05:30:42
x1,x2,y1,y2>10^9 in my experience. Leppy's comment wasn't really helpful (no offense). |
|
Archangel:
2015-03-08 21:52:34
Handle 0 case properly... costed me a WA |
|
SM_92:
2015-03-06 17:56:00
2 WA only because of using int
|
|
Daksh:
2015-02-24 18:47:01
Easy Math :) |
|
Rishabh:
2015-02-06 12:06:03
constraints will require an unsigned 4 bit integer data type
|
|
maradona:
2015-01-24 15:22:55
The question that arises, why are the constraints hidden?? |
|
Sahil Dua:
2015-01-05 23:38:32
177th one to get AC :D |
|
LeppyR64:
2014-12-12 17:17:40
0 <= x1,y1,x2,y2 < 10^5 Last edit: 2014-12-12 18:30:45 |
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 |