#158. 巧克力包裹重量计算
巧克力包裹重量计算
Chocolate Packaging
Background
You are preparing chocolate packages for customers. You need to accurately pack a specified weight of chocolate according to customer requirements.
Problem Description
We want to make a package of kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return if it can't be done.
Input Format
Input is given from standard input in the following format.
small big goal
Where:
smallis the number of available small chocolate bars.bigis the number of available big chocolate bars.goalis the target total weight (in kilos).
Output Format
Output to standard output in the following format.
number_of_small_bars
Where number_of_small_bars is the number of small bars to use, or if it cannot be done.
Sample
4 1 9
4
Sample Explanation
The goal is kilos. We have big bar ( kilos) and small bars ( kilo each). Prioritize using big bars: use big bar, remaining kilos needed. We have small bars, which is enough to provide kilos. So, small bars are needed.
4 1 10
-1
Sample Explanation
The goal is kilos. We have big bar ( kilos) and small bars ( kilo each). Prioritize using big bars: use big bar, remaining kilos needed. We only have small bars, which is not enough to provide kilos. Therefore, it cannot be done, return .
4 1 7
2
Sample Explanation
The goal is kilos. We have big bar ( kilos) and small bars ( kilo each). Prioritize using big bars: use big bar, remaining kilos needed. We have small bars, which is enough to provide kilos. So, small bars are needed.
Constraints
No additional constraints. Input data is guaranteed to be within standard integer types.