A1166 | [COCI-2008_2009-contest5]#1 JABUKA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/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:
1. One friend gets all 4 red and all 8 green apples;
2. Two friends each receive 2 red apples and 4 green apples;
3. 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.
For example, if Mirko has 4 red and 8 green apples, he can divide them in three ways:
1. One friend gets all 4 red and all 8 green apples;
2. Two friends each receive 2 red apples and 4 green apples;
3. 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 ≤ R, G ≤ 1 000 000 000),
the numbers of red and green apples.
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 greed apples each of them will receive.
Each distribution needs to be output exactly once. You may output the distributions in any order.
Each distribution needs to be output exactly once. You may output the distributions in any order.
输入输出样例
输入 #1
4 8
输出 #1
1 4 8 2 2 4 4 1 2
输入 #2
15 12
输出 #2
3 5 4 1 15 12
输入 #3
42 105
输出 #3
1 42 105 3 14 35 7 6 15 21 2 5
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted