#4939. Glass and Mug

0
    ID: 4939 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc332BGESP 1级枚举(单层循环)模拟

Glass and Mug

Glass and Mug

题目描述

AtCoder Inc. sells glasses and mugs. Takahashi has a glass with a capacity of GG milliliters and a mug with a capacity of MM milliliters.
Here, G<M. Initially, both the glass and the mug are empty.
After performing the following operation KK times, determine how many milliliters of water are in the glass and the mug, respectively.

当玻璃被注满水时,也就是玻璃恰好含有 GG 毫升水,把玻璃中的所有水倒掉。 否则,如果杯子是空的,就把杯子装满水。 否则,把水从杯子中倒入玻璃,直到杯子为空或玻璃被注满为止。

输入格式

The input is given from Standard Input in the following format: KK GG MM

输出格式

Print the amounts, in milliliters, of water in the glass and the mug, in this order, separated by a space, after performing the operation KK times.

5 300 500
200 500
5 100 200
0 0

提示

1≤K≤1001\leq K\leq 100 1\leq G<M\leq 1000 GG, MM, and KK are integers.该操作按如下方式进行。最初,玻璃和杯子都是空的。

把杯子装满水。玻璃有 00 毫升,杯子有 500500 毫升的水。 把水从杯子中倒入玻璃,直到玻璃被注满。玻璃有 300300 毫升,杯子有 200200 毫升的水。 把玻璃中的所有水倒掉。玻璃有 00 毫升,杯子有 200200 毫升的水。 把水从杯子中倒入玻璃,直到杯子为空。玻璃有 200200 毫升,杯子有 00 毫升的水。 把杯子装满水。玻璃有 200200 毫升,杯子有 500500 毫升的水。

因此,经过五次操作后,玻璃有 200200 毫升,杯子有 500500 毫升的水。 因此,按此顺序用空格分隔打印 200200 和 500500。

标签: AtCoder|abc332B

来源

AtCoder|abc332B