QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21162. 牛乳のバケツ

Statistics

Farmer John はちょうど $M$ 単位の牛乳($1 \leq M \leq 1,000$)の注文を受け、すぐに用意する必要があります。しかし高級な搾乳機が壊れ、整数容量 $X$、$Y$、$M$ のバケツ($1 \leq X < Y < M$)しかありません。最初は三つとも空です。次の二種類の操作を何度でも行えます。

  • 最小の容量 $X$ のバケツを $X$ 単位で満たし、容量 $M$ のバケツに注ぎます。ただし容量 $M$ のバケツがあふれない場合に限ります。
  • 中間の容量 $Y$ のバケツを $Y$ 単位で満たし、容量 $M$ のバケツに注ぎます。ただし容量 $M$ のバケツがあふれない場合に限ります。

FJ は容量 $M$ のバケツを満たせないかもしれないと知っています。最大でどれだけ牛乳を入れられるか求めてください。

入力

唯一の行に空白区切りの $X$、$Y$、$M$ があります。

出力

FJ が容量 $M$ のバケツに入れられる最大の牛乳量を出力してください。

入出力例

入力 1

17 25 77

出力 1

76

注記

容量 17 のバケツを 3 回、容量 25 のバケツを 1 回満たし、計 76 単位になります。

問題作成者:Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.