#P7679. [COCI 2008/2009 #5] JABUKA

[COCI 2008/2009 #5] JABUKA

Description

Mirko has RR red apples and GG green apples. He wants to give them to several friends so that every 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 apples for himself.

For example, suppose Mirko has 44 red apples and 88 green apples. Then all possible ways to distribute the apples are:

  • Give them to one friend, that is, give all 44 red apples and 88 green apples to this friend.
  • Give them to two friends, where each friend receives 22 red apples and 44 green apples.
  • Give them to four friends, where each friend receives 11 red apple and 22 green apples.

Now given R,GR, G, please help Mirko find all possible ways to distribute the apples. It can be proven that at least one valid distribution always exists.

Input Format

The input contains only one line with two integers R,GR, G, representing the number of red apples and the number of green apples.

Output Format

Output several lines. Each line contains three integers: 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 increasing order of the number of friends.

It is guaranteed that the output will not exceed the output limit.

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

Hint

Constraints

For all testdata, 1R,G1091\leqslant R,G\leqslant 10^9.

Source

This problem comes from COCI 2008-2009 CONTEST 5 T2 JABUKA. Using the original testdata settings, the full score is 5050 points.

Translated and organized by Eason_AC.

Translated by ChatGPT 5