103321: [Atcoder]ABC332 B - Glass and Mug

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

AtCoder Inc. sells glasses and mugs.

Takahashi has a glass with a capacity of $G$ milliliters and a mug with a capacity of $M$ milliliters.
Here, $G<M$.

Initially, both the glass and the mug are empty.
After performing the following operation $K$ 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 $G$ 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

  • $1\leq K\leq 100$
  • $1\leq G<M\leq 1000$
  • $G$, $M$, and $K$ are integers.

Input

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

$K$ $G$ $M$

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 $K$ 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 $0$ milliliters, and the mug has $500$ milliliters of water.
  • Transfer water from the mug to the glass until the glass is filled. The glass has $300$ milliliters, and the mug has $200$ milliliters of water.
  • Discard all the water from the glass. The glass has $0$ milliliters, and the mug has $200$ milliliters of water.
  • Transfer water from the mug to the glass until the mug is empty. The glass has $200$ milliliters, and the mug has $0$ milliliters of water.
  • Fill the mug with water. The glass has $200$ milliliters, and the mug has $500$ milliliters of water.

Thus, after five operations, the glass has $200$ milliliters, and the mug has $500$ milliliters of water. Hence, print $200$ and $500$ in this order, separated by a space.


Sample Input 2

5 100 200

Sample Output 2

0 0

Input

Output

分数:200分

问题描述

AtCoder Inc. 销售玻璃杯马克杯

Takahashi 有一个容量为 $G$ 毫升的玻璃杯和一个容量为 $M$ 毫升的马克杯。这里,$G

最初,玻璃杯和马克杯都是空的。

执行以下操作 $K$ 次后,分别确定玻璃杯和马克杯中的水的毫升数。

  • 当玻璃杯装满水时,即玻璃杯中恰好有 $G$ 毫升的水,将玻璃杯中的所有水倒掉。
  • 否则,如果马克杯为空,则将马克杯装满水。
  • 否则,将马克杯中的水转移到玻璃杯中,直到马克杯为空或玻璃杯装满水。

约束条件

  • $1\leq K\leq 100$
  • $1\leq G
  • $G$,$M$ 和 $K$ 都是整数。

输入

输入从 Standard Input 按照以下格式给出:

$K$ $G$ $M$

输出

在执行 $K$ 次操作后,按照空格分隔的顺序打印玻璃杯和马克杯中的水的毫升数。


样例输入 1

5 300 500

样例输出 1

200 500

操作将按以下方式执行。最初,玻璃杯和马克杯都是空的。

  • 将马克杯装满水。玻璃杯中有 $0$ 毫升水,马克杯中有 $500$ 毫升水。
  • 将马克杯中的水转移到玻璃杯中,直到玻璃杯装满。玻璃杯中有 $300$ 毫升水,马克杯中有 $200$ 毫升水。
  • 将玻璃杯中的所有水倒掉。玻璃杯中有 $0$ 毫升水,马克杯中有 $200$ 毫升水。
  • 将马克杯中的水转移到玻璃杯中,直到马克杯为空。玻璃杯中有 $200$ 毫升水,马克杯中有 $0$ 毫升水。
  • 将马克杯装满水。玻璃杯中有 $200$ 毫升水,马克杯中有 $500$ 毫升水。

因此,经过五次操作后,玻璃杯中有 $200$ 毫升水,马克杯中有 $500$ 毫升水。 因此,按照空格分隔的顺序打印 $200$ 和 $500$。


样例输入 2

5 100 200

样例输出 2

0 0

加入题单

算法标签: