spoj#NAJGC. Game of chocolate
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 &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 any case probability cames zero, just print ‘0’ (Case x: 0).
Sample:
Input |
Output |
Authored By: Tanvir Hasan Anick