P29679 [洛谷] [COCI2008-2009#5] JABUKA
普及
题目描述

Problem Description

Mirko has $R$ red apples and $G$ green apples. He wants to distribute them among several friends such that each friend receives the same number of red apples and the same number of green apples. Since Mirko himself does not like apples, he will not keep any for himself.

For example, if Mirko has 4 red apples and 8 green apples, the following are all possible ways to distribute the apples:

  • Give all 4 red apples and 8 green apples to one friend.
  • Give 2 red apples and 4 green apples to each of two friends.
  • Give 1 red apple and 2 green apples to each of four friends.

Given $R$ and $G$, help Mirko find all possible ways to distribute the apples. It can be proven that there is always a way to distribute the apples.

Input Format

The input consists of a single line with two integers $R$ and $G$, representing the number of red apples and green apples, respectively.

Output Format

Output several lines, each containing three integers representing the number of friends, the number of red apples each friend receives, and the number of green apples each friend receives.

If there are multiple solutions, output them in ascending order of the number of friends.

The data guarantees that the output will not exceed the limit.

Sample Input and Output

Sample Input #1

4 8

Sample Output #1

1 4 8
2 2 4
4 1 2

Sample Input #2

15 12

Sample Output #2

1 15 12
3 5 4

Sample Input #3

42 105

Sample Output #3

1 42 105
3 14 35
7 6 15
21 2 5

Notes

[Data Range]

For all data, $1 \leqslant R, G \leqslant 10^9$.

[Problem Source]

This problem is from COCI 2008-2009 CONTEST 5 T2 JABUKA, configured according to the original problem data, with a full score of $50$ points.

Provided by Eason_AC for translation and arrangement.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 8
样例输出
1 4 8 2 2 4 4 1 2