#K10671. Minimum Hops
Minimum Hops
Minimum Hops
Zappy the kangaroo loves hopping around the Outback. In each hop, he can move exactly A, B, or C meters forward. His goal is to reach exactly D meters starting from 0. Determine the minimum number of hops required to reach D meters. If it is impossible to exactly reach D meters using any combination of hops, output Impossible
.
The problem can be formally described by the equation:
\(a \times A + b \times B + c \times C = D\)
where a, b, and c are non-negative integers representing the count of hops of lengths A, B, and C respectively. The objective is to minimize \(a + b + c\).
inputFormat
The input consists of a single line containing four space-separated integers: A, B, C, and D, where A, B, C are the allowed hop distances and D is the target distance.
outputFormat
Output a single line with the minimum number of hops required to reach exactly D. If it is not possible, output 'Impossible'.## sample
2 3 5 11
3
</p>