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
nadstratosfer:
2017-09-27 07:29:12
Output "1/1" for probability = 1 else WA. |
|
dark_lord1:
2017-08-12 16:37:50
Easy..Use 64 bit integers and consider the case x1=y1=0 |
|
rishabh_1997:
2016-02-23 21:40:33
Take care of x1=0 & y1=0 case.
|
|
raghav12345:
2015-12-19 06:16:05
use 1 as 1/1 not 1 costed me 1 WA |
|
sy_117:
2015-10-21 12:40:01
Really nice question on probability!!!!!! AC in one go :)
|
|
dwij28:
2015-09-08 16:46:00
I love Probability.. :D Use long long else you shall be awarded with a WA like me .. :| |
|
anuveshkothari:
2015-09-06 18:43:38
ignoring the zero probability case costed me 2 WA otherwise easy |
|
Shivam Singh:
2015-08-22 04:00:50
was getting SIGFPE error due to ignoring x1=y1=0 case,
|
|
Shubham Sinha:
2015-04-04 13:14:20
By the way easy one for 0.25 points. |
|
Shubham Sinha:
2015-04-04 13:08:56
Use while loop, using for loop cause me 3 TLE's. |
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 |