cashier.in
Professor C. Ess bought 4 items at the 7-Eleven convenience store. As the cashier, Alec, was a former computer science student, Professor Ess thought it wise to double-check how his bill of $7.11 was calculated. Alec told him that he simply multiplied the prices of the items together. When Professor Ess objected that the amounts should have been added instead of multiplied, Alec replied that it didn’t matter; the amount was the same either way. Sure enough, when Professor Ess multiplied his items for $1.20, $1.25, $1.50, and $3.16 together, the result was the same as their sum.
You are given a list of dollar amounts, and you are asked to find the prices of 4 items that, when multiplied, achieve exactly the same value as when added. There may be no solution, one solution, or distinct multiple solutions.
The input is a list of positive dollar (2 decimal place) amounts less than 20.00, one per line. The list is terminated by a value of 0.00, which is not to be solved.
The first line of output for each input line is the amount
of the bill. If there are no solutions, the next line
is "No solutions
". If there is one or more
solutions, each solution must be on a separate line, in the form
"Solution N: I1, I2, I3, I4
",
where N is the number of the solution, and I1, I2, I3, I4
are
the item prices (2 decimal places) in increasing order. If there are multiple
solutions they must be distinct and listed in lexicographically increasing
order, as done in the sample output. There must be a blank line following each
set of solutions.
7.11 0.50 7.20 0.00
7.11 Solution 1: 1.20, 1.25, 1.50, 3.16 0.50 No solutions 7.20 Solution 1: 0.80, 1.50, 2.40, 2.50 Solution 2: 1.00, 1.20, 2.00, 3.00 Solution 3: 1.00, 1.50, 1.50, 3.20