SP10210 TRANSFER - After Party Transfers
Description
You've been to a potluck party (party where each person contributes food), but some people are angry that they spent more money preparing their dish than the others. Now they want you (they span the bottle) to figure out how the participants of the party can, in the _fewest_ amount of transfers, become even.
To clarify, you are free to transfer money between them in any way you like, but eventually the money they spent on their dishes, plus the money they received, minus the money the sent, must be equal for all participants.
Input Format
The first line contains C ∈ \[0..10\] - the number of test cases.
For each test case, the first line contains the number N ∈ \[0..20\] - the number of people at the party.
The following N lines contains a interger x $ _{i} $ ∈ \[0,10^6\] representing the amount of money the ith persons dish cost.
Output Format
For each testcase:
The first line should be the minimal amount of transfers needed to even out the party budget.
The following lines should be on the form "a -> b: t", where a,b ∈ \[0..N) and represent that person 'a' must transfer 't' money to person 'b'. t is here a floating point number of at least 6 digits precision. (Notice: that is 6 digits precision after adding together your in and out flows)
In case of multiple best solutions exists, print any.