Bottled-Up Feelings
InterviewTime limit1sMemory limit256 MB
Find counts of two bottle sizes that sum exactly to the shipment volume with the fewest bottles, or report Impossible.
- Level
Easy2 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
Peter has a large shipment of fuel oil coming in and nothing good to put it in. All he owns is a set of large bottles that all hold the same volume, plus a set of smaller bottles that also all hold the same volume, smaller than the large ones. Given the volume of the shipment, he wants to store the oil so that
- all of the oil is stored,
- every bottle he uses is filled to the top, and
- the number of bottles used is as small as possible.
Peter already worked out the answer for the bottles he owns, but he keeps wondering what happens when the bottle volumes change. Given the volume of the shipment and the two bottle volumes, work out the answer for him.
Input
The first line contains three positive integers , and separated by spaces. is the volume of the shipment, with . and are the volumes of the large bottle and the small bottle, with , and .
Output
Print the number of bottles of volume and the number of bottles of volume that meet all three conditions, separated by a space on one line. If no such split exists, print Impossible. Several splits can store the oil exactly, but only one of them uses the fewest bottles, so the answer is unique.