#4939. Glass and Mug
Glass and Mug
Glass and Mug
题目描述
AtCoder Inc. sells glasses and mugs.
Takahashi has a glass with a capacity of milliliters and a mug with a capacity of milliliters.
Here, G<M.
Initially, both the glass and the mug are empty.
After performing the following operation times, determine how many milliliters of water are in the glass and the mug, respectively.
当玻璃被注满水时,也就是玻璃恰好含有 毫升水,把玻璃中的所有水倒掉。 否则,如果杯子是空的,就把杯子装满水。 否则,把水从杯子中倒入玻璃,直到杯子为空或玻璃被注满为止。
输入格式
The input is given from Standard Input in the following format:
输出格式
Print the amounts, in milliliters, of water in the glass and the mug, in this order, separated by a space, after performing the operation times.
5 300 500
200 500
5 100 200
0 0
提示
1\leq G<M\leq 1000 , , and are integers.该操作按如下方式进行。最初,玻璃和杯子都是空的。
把杯子装满水。玻璃有 毫升,杯子有 毫升的水。 把水从杯子中倒入玻璃,直到玻璃被注满。玻璃有 毫升,杯子有 毫升的水。 把玻璃中的所有水倒掉。玻璃有 毫升,杯子有 毫升的水。 把水从杯子中倒入玻璃,直到杯子为空。玻璃有 毫升,杯子有 毫升的水。 把杯子装满水。玻璃有 毫升,杯子有 毫升的水。
因此,经过五次操作后,玻璃有 毫升,杯子有 毫升的水。
因此,按此顺序用空格分隔打印 和 。
标签: AtCoder|abc332B
来源
AtCoder|abc332B