All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Alice and Bob, both have to drink water. But they both don't want to go, so they will play a game to decide who will fetch water for both of them. Alice will choose a number randomly between 1 and N (both inclusive) and Bob will choose a number randomly between 1 and M (both inclusive). Both will write their numbers on a slip of paper. If sum of numbers choosen by both is odd, then Alice will go, else Bob will go.
What is probability that Alice will go?
First line contains, T, the number of testcases. Each testcase consists of N and M in one line, separated by a space.
For each test case, output a single line containing probability as an irreducible fraction.
- 1 ≤ T ≤ 105
- 1 ≤ N,M ≤ 109
Input: 3 1 1 1 2 2 3 Output: 0/1 1/2 1/2
#test1: The only way is when Alice and Bob both choose 1. So, Alice won't have to go because sum is even.
#test2: The different ways are (1,1) and (1,2), where first term denotes the number choosen by Alice. So of all possible cases (ie. 2) in only 1 case Alice has to go. Therefore, probability is 1/2.
#test3: The different ways are (1,1), (1,2), (1,3), (2,1), (2,2), (2,3) where first term denotes the number choosen by Alice. So of all possible cases (ie. 6) in only 3 cases Alice has to go. Therefore, probability is 1/2.
|Tags||ad-hoc, combinatorics, darkshadows, june14, simple|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions