SP25393 DWRONG - Do It Wrong, Get It Right
Description
In elementary school, students learn to subtract fractions by first getting a common denominator and then subtracting the numerators. However, sometimes a student will work the problem incorrectly and still arrive at the correct answer. For example, for the problem
5/4 - 9/12
one can subtract the numbers in the numerator and then subtract the numbers in the denominator, simplify and get the answer. i.e.
5/4 - 9/12 = -4/-8 = 4/8 = 1/2
For a given fraction b/n, your task is to find all of the values a and m, where a>=0 and m>0, for which
a/m - b/n = (a-b)/(m-n)
Input Format
There will be several test cases in the input. Each test case will consist of a single line with two integers, b and n (1
Output Format
For each case, output all of the requested fractions on a single line, sorted from smallest to largest. For equivalent fractions, print the one with the smaller numerator first. Output each fraction in the form “a/m” with no spaces immediately before or after the “/”. Output a single space between fractions. Output no extra spaces, and do not separate answers with blank lines.