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

说明

FJ 装满容量 17 的桶三次、容量 25 的桶一次,共积累 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.