시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 550 90 45 14.286%

문제

초등학교에서 학생들은 분수 뺄셈을 하는 법을 배운다. 하지만, 상근이는 분수 뺄셈을 아직도 제대로 하는 법을 모른다.

예를 들어, 아래와 같은 분수 뺄셈이 있다.

\[\frac{5}{4} - \frac{9}{12}\]

상근이는 분모 끼리 빼고, 분자 끼리 빼는 방법으로 뺄셈을 한다. 아래 그림을 보자.

\[\frac{5}{4} - \frac{9}{12} = \frac{-4}{-8} = \frac{4}{8} = \frac{1}{2}\]

그런데, 신기하게도 이 방법이 실제 결과와 같은 경우가 있다.

분수 b/n이 주어진다. 이때, 아래 식을 만족하는 모든 a와 m을 찾는 프로그램을 작성하시오. (a ≥ 0, m > 0)

\[\frac{a}{m} - \frac{b}{n} = \frac{a-b}{m-n}\]

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, b와 n이 주어진다. (1 ≤ b, n ≤ 106) 입력의 마지막 줄에는 0이 두 개 주어진다.

출력

각 테스트 케이스에 대해서, 문제의 조건을 만족하는 분수를 작은 것부터 크기 순서대로 모두 출력한다. 출력하고자 하는 분수의 크기가 같은 경우에는 분자의 크기가 작은 것 부터 출력한다. 분수는 항상 a/m 형태로 출력해야 하며, /의 앞과 뒤에 공백을 출력하면 안된다. 분수와 분수 사이에는 공백을 하나 출력한다.

예제 입력 1

9 12
12 14
4 12
0 0

예제 출력 1

0/24 5/20 8/16 8/8 5/4
0/28 9/21 9/7
0/24 3/18 3/6
W3sicHJvYmxlbV9pZCI6IjQ3ODIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJkODRcdWMyMTggXHViZTg0XHVjMTQ4IiwiZGVzY3JpcHRpb24iOiI8cD5cdWNkMDhcdWI0ZjFcdWQ1NTlcdWFkNTBcdWM1ZDBcdWMxMWMgXHVkNTU5XHVjMGRkXHViNGU0XHVjNzQwIFx1YmQ4NFx1YzIxOC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