#158. 巧克力包裹重量计算

    ID: 158 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatLogic-2gesp1条件结构数学基础

巧克力包裹重量计算

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 goalgoal 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 1-1 if it can't be done.

Input Format

Input is given from standard input in the following format.

small big goal

Where:

  • small is the number of available small chocolate bars.
  • big is the number of available big chocolate bars.
  • goal is 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 1-1 if it cannot be done.

Sample

4 1 9
4

Sample Explanation

The goal is 99 kilos. We have 11 big bar (55 kilos) and 44 small bars (11 kilo each). Prioritize using big bars: use 11 big bar, remaining 95=49 - 5 = 4 kilos needed. We have 44 small bars, which is enough to provide 44 kilos. So, 44 small bars are needed.

4 1 10
-1

Sample Explanation

The goal is 1010 kilos. We have 11 big bar (55 kilos) and 44 small bars (11 kilo each). Prioritize using big bars: use 11 big bar, remaining 105=510 - 5 = 5 kilos needed. We only have 44 small bars, which is not enough to provide 55 kilos. Therefore, it cannot be done, return 1-1.

4 1 7
2

Sample Explanation

The goal is 77 kilos. We have 11 big bar (55 kilos) and 44 small bars (11 kilo each). Prioritize using big bars: use 11 big bar, remaining 75=27 - 5 = 2 kilos needed. We have 44 small bars, which is enough to provide 22 kilos. So, 22 small bars are needed.

Constraints

No additional constraints. Input data is guaranteed to be within standard integer types.