Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
||||||
2014-11-04 15:26:53 SHASHANK PAL
My 100th AC solution :D |
||||||
2014-11-02 11:23:28 fitcat
My AC solution assumed x1, y1, x2 and y2 are all within signed 32-bit integers. Note that for probability 1, output 1/1. |
||||||
2014-11-01 03:41:30 Jacob Plachta
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 |