shunfurh 于 2017.09.12 14:02 提问

The Trip

A number of students are members of a club that travels annually to exotic locations. Their destinations in the past have included Indianapolis, Phoenix, Nashville, Philadelphia, San Jose, and Atlanta. This spring they are planning a trip to Eindhoven.

The group agrees in advance to share expenses equally, but it is not practical to have them share every expense as it occurs. So individuals in the group pay for particular things, like meals, hotels, taxi rides, plane tickets, etc. After the trip, each student's expenses are tallied and money is exchanged so that the net cost to each is the same, to within one cent. In the past, this money exchange has been tedious and time consuming. Your job is to compute, from a list of expenses, the minimum amount of money that must change hands in order to equalize (within a cent) all the students' costs.

Input

Standard input will contain the information for several trips. The information for each trip consists of a line containing a positive integer, n, the number of students on the trip, followed by n lines of input, each containing the amount, in dollars and cents, spent by a student. There are no more than 1000 students and no student spent more than \$10,000.00. A single line containing 0 follows the information for the last trip.

Output

For each trip, output a line stating the total amount of money, in dollars and cents, that must be exchanged to equalize the students' costs.

Sample Input

3
10.00
20.00
30.00
4
15.00
15.01
3.00
3.01
0

Sample Output

\$10.00
\$11.99

2个回答

shen_wei      2017.09.12 15:39

caozhy      2017.09.13 00:40

he is finding this trip very exciting
<br />Why ing?<br /> <br />be finding 可理解成“发现”<br /> <br />http://zhidao.baidu.com/question/88761913.htmlfind+宾语+形容词做宾补<br /> find trip exciting;find the room clean<br /> 注意，在本句中用的是find的进行时态。<br /><br /> 在收听外台的广播中经常能听到find不用一般式，而用进行式。<br /> eg:We're fi
POJ1041 John's trip 欧拉回路路径查找

(Manual) round-trip time(RTT)
2014-02-11 wcdj Round-trip time (RTT), also called round-trip delay, is the time required for a signal pulse orpacket totravel from a specific source to a specific destination and back again.
arm-linux-trip
<br />来源：http://blog.sina.com.cn/s/blog_6035432c0100jnuc.html<br /> <br />今天看一个Makefile，<br />CROSS_COMPILE=arm-linux-<br />STRIP = \$(CROSS_COMPILE)strip<br />arm-linux-strip是什么东西没见过，只见过arm-linux-gcc<br />估计和arm-linux-gcc一样是一个工具吧，查了网上资料，和少。<br />想既然有arm-li
Ant Trip （一笔画问题）
Ant Country consist of N towns.There are M roads connecting the towns.  Ant Tony,together with his friends,wants to go through every part of the country.  They intend to visit every road , and e
DSP28335 SPWM之Trip-Zone中断

hdu3018Ant Trip【欧拉道路数量 并查集】
Description Ant Country consist of N towns.There are M roads connecting the towns. Ant Tony,together with his friends,wants to go through every part of the country. They intend to visit e
Gym 101572 K.Kayaking Trip【二分+贪心】