시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 552 92 46 14.557%

문제

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

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

\[\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
W3sicHJvYmxlbV9pZCI6IjQ3ODIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJkODRcdWMyMTggXHViZTg0XHVjMTQ4IiwiZGVzY3JpcHRpb24iOiI8cD5cdWNkMDhcdWI0ZjFcdWQ1NTlcdWFkNTBcdWM1ZDBcdWMxMWMgXHVkNTU5XHVjMGRkXHViNGU0XHVjNzQwIFx1YmQ4NFx1YzIxO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