Double Check
Practice
0 (0 votes)
Easy
Problem
34% Success 312 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

A computer program named Eunoia is successful if it is able to place two checkers in a $$N$$ x $$M$$ grid-board(a rectangular board that has $$N$$ x $$M$$ cells) such that both the below conditions are satisfied :

  1.   the row number of the checkers are not equal.
  2.   the column number of the checkers are not equal.

Else, the program has failed.

Find the success probability of Eunoia if it randomly places the checkers on the board.

Note: Both the checkers cannot be placed in the same cell.

Input Format: -

First line contains $$T$$ – no of testcases. Next $$T$$ lines has two spaced integers $$N$$ and $$M$$.

Output Format: -

Print $$T$$ lines, the ith line corresponds to the answer of ith test case where two spaced integers $$P$$ and $$Q$$ are output denoting the success probability, $$P$$/$$Q$$ where P and Q are co-prime.

if the probability is 0, output "0 1" in-place of P and Q.

Constraints:

1 <= $$T$$ <= 100

1 <= $$N$$ , $$M$$<= 109

$$N$$ +  $$M$$ >= 3

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
2 votes
Tags:
MathematicsEasyEasy
Points:20
7 votes
Tags:
MathematicsProbability and StatisticsEasy
Points:20
4 votes
Tags:
ProbablityException handlingGrammar-VerifiedProbability and StatisticsHiringBasic ProbabilityReadyMathematicsApprovedEasyProbability
Editorial

No editorial available for this problem.