Jabuka
의견: 0
Mirko has \(R\) red and \(G\) green apples to share with some of his friends, so that all of them receive the same number of red apples and also the same number of green apples. Mirko does not like apples himself so he doesn't want to be left with any apples afterward.
For example, if Mirko has \(4\) red and \(8\) green apples, he can divide them in three ways:
- One friend gets all \(4\) red and all \(8\) green apples;
- Two friends each receive \(2\) red apples and \(4\) green apples;
- Four friends each receive \(1\) red and \(2\) green apples.
Write a program that outputs all ways for Mirko to divide his apples. Assume Mirko has an infinite supply of friends to give apples to.
The first line contains two positive integers \(R\) and \(G\) separated by a space (\(1 \le R, G \le 1\,000\,000\,000\)), the numbers of red and green apples.
For each possible distribution, output three integers \(N\), \(X\) and \(Y\) on one line. The number \(N\) is the number of friends that will receive apples. The numbers \(X\) and \(Y\) tell how many red and green apples each of them will receive.
Each distribution needs to be output exactly once. You may output the distributions in any order.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
Subtask 1 | 50점 |
4 81 4 8
2 2 4
4 1 215 123 5 4
1 15 1242 1051 42 105
3 14 35
7 6 15
21 2 5평가 및 의견
Jabuka
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Jabuka