2 shunfurh 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
shen_wei   Ds   Rxr 2017.09.12 15:39
已采纳
caozhy
caozhy   Ds   Rxr 2017.09.13 00:40
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
错误输入(Trip_Zone)子模块的工作特性
错误输入信号                              ~ ,在低电平时,表示输入了一个错误信号,错误事件发生。每个EPWM模块可以被独立地配置为使能或者禁止这个错误输入信号 。如果要在特定的EPWM模块中使能,可通过EPWM模块的TZSEL寄存器来设置。        输入可以同步系统时钟(SYSCLKOUT)输入,也可以作为异步信号输入,同时,作为复用的IO, 信号
雅思听力听写练习之 C7T2-2--Boat Trip
这次听写感觉大部分的词还是能听明白的,但是,需要断句,长句子听完,记不出清楚,短句子能写下来。大约听了半个小时,这一篇才算完成。      下面是听写的记录:
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 欧拉回路路径查找
题目链接:http://poj.org/problem?id=1041 题目大意:一个城镇有n个二叉路口,这些路口由m条街道连接,某人想要从某个路口出发,经过所有的街道且每条街道只走一次,再回到出发点,让找出一个可行的路线,依次输出经过的街道编号,如果有多条路线,选择字典序最小的一条输出。 分析:经典的欧拉回路问题。因为是要输出街道编号,建图需要一些技巧。 实现代码如
(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中断
微信订阅号--DSP学习笔记
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【二分+贪心】
题目大意: 一共有三种人,每种人的数量为b,n,c; 其每一种人的力量值为sb,sn,sc; 现在保证b+n+c是偶数,需要我们将这b+n+c个人分成(b+n+c)/2对,然后每对选手放到一个倍值为c【i】的船上,对应这艘的能力值为c【i】*(s1+s2); 现在希望我们构造出来的方案中,船的最小能力值尽可能的大。 思路: ①首先答案有二分单调性,那么我们考虑二