1. 程式人生 > >硬幣面值問題

硬幣面值問題

You know all coin denominations used in Colorland, but youdon't know their colors.You don't even know the set of colorsused on the coins.



For each denomination, you'd liketo know the color of coins of this denomination. To accomplish this,you've got a credit card with an infinite amount of money. You canperform a single query to an ATM which can also provide you with aninfinite amount of money. The query is described by a positiveinteger X, which means that you want to receive exactly X units ofmoney from the ATM. The ATM will provide you with the requestedamount.You also know that the requested amount will be paid usingthe smallest possible number of coins.
(Note that this rulealways uniquely determines the set of coins chosen to make thepayment.)



Return "Possible" (quotes forclarity) if it's possible to determine the color of coins of eachdenomination, and return "Impossible" otherwise.