#149. 砖墙制作可行性判断

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

砖墙制作可行性判断

Make Bricks

Background

Congcong is playing a building block game.

Problem Description

We want to make a row of bricks that is goalgoal inches long. We have a number of small bricks (11 inch each) and big bricks (55 inches each). Return true if it is possible to make the goalgoal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

Input Format

Input is given from standard input in the following format.

small big goal

Output Format

Output is printed to standard output in the following format.

result

Sample

3 1 8
true
3 1 9
false
3 2 10
true

Sample Explanation

Sample 1: small = 3, big = 1, goal = 8. We can use 11 big brick (55 inches) and 33 small bricks (33 inches), totaling 5+3=85+3=8 inches. So, return true.

Sample 2: small = 3, big = 1, goal = 9. Even using all bricks, the maximum length is 1×5+3×1=81 \times 5 + 3 \times 1 = 8 inches, which cannot reach 99 inches. So, return false.

Sample 3: small = 3, big = 2, goal = 10. We can use 22 big bricks (1010 inches) and 00 small bricks, totaling 1010 inches. So, return true.

Constraints

Time limit 11s, Memory limit 10241024 KiB for each test case.