#abc332b. B - Glass and Mug
B - Glass and Mug
Score : points
问题描述
高桥拥有一个容量为 毫升的玻璃杯和一个容量为 毫升的马克杯。这里,。
最初,玻璃杯和马克杯都是空的。在执行以下操作 次后,确定玻璃杯和马克杯中分别有多少毫升的水。
- 当玻璃杯装满水,即玻璃杯内恰好含有 毫升水时,将玻璃杯中的所有水倒掉。
- 否则,如果马克杯是空的,则将马克杯装满水。
- 否则,将马克杯中的水转移至玻璃杯,直到马克杯变空或玻璃杯装满水为止。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
AtCoder Inc. sells glasses and mugs.
Takahashi has a glass with a capacity of milliliters and a mug with a capacity of milliliters.
Here, .
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.
- When the glass is filled with water, that is, the glass contains exactly milliliters of water, discard all the water from the glass.
- Otherwise, if the mug is empty, fill the mug with water.
- Otherwise, transfer water from the mug to the glass until the mug is empty or the glass is filled with water.
Constraints
- , , and are integers.
Input
The input is given from Standard Input in the following format:
Output
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.
Sample Input 1
5 300 500
Sample Output 1
200 500
The operation will be performed as follows. Initially, both the glass and the mug are empty.
- Fill the mug with water. The glass has milliliters, and the mug has milliliters of water.
- Transfer water from the mug to the glass until the glass is filled. The glass has milliliters, and the mug has milliliters of water.
- Discard all the water from the glass. The glass has milliliters, and the mug has milliliters of water.
- Transfer water from the mug to the glass until the mug is empty. The glass has milliliters, and the mug has milliliters of water.
- Fill the mug with water. The glass has milliliters, and the mug has milliliters of water.
Thus, after five operations, the glass has milliliters, and the mug has milliliters of water. Hence, print and in this order, separated by a space.
Sample Input 2
5 100 200
Sample Output 2
0 0
update @ 2024/3/10 01:17:03