Problem E
Bottled-Up Feelings

Peter is expecting a large shipment of fuel oil, but he has a small problem (doesn’t everyone in these programming problems!). The only containers he has are a set of large bottles (each with the same volume) and a set of smaller bottles (also each with the same, but smaller volume). Given the volume of the shipment of oil, he would like to store the oil in the bottles so that

  1. all of the oil is stored,

  2. each bottle is filled to the top, and

  3. the minimum number of bottles is used.

While Peter thinks he has solved this problem for his given bottle sizes, he often spends hours wondering what would happen if his bottles had different volumes (apparently Peter doesn’t lead the most exciting life).


The input consists of a single line containing three positive integers $s$ $v_1$ $v_2$, where $s \leq 10^6$ is the volume of the shipment, and $v_1, v_2 \leq 10^6$ are the volumes of the two types of bottles, with $v_1 > v_2$.


Output the number of bottles of size $v_1$ and the number of bottles of size $v_2$ which satisfy Peter’s two conditions. If the conditions cannot be met, output Impossible.

Sample Input 1 Sample Output 1
1000 9 7
108 4
Sample Input 2 Sample Output 2
1000 900 7
Sample Input 3 Sample Output 3
1000 10 7
100 0

Please log in to submit a solution to this problem

Log in