编程介的小学生 2019-09-15 21:58 采纳率: 20.5%
浏览 147

Treasure Division 怎么来编程代码

Problem Description
Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts.

Input
Input contains multiple cases.Test cases are separated by several blank lines.

Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i.

Output
For each case,output the least difference that could be found in one fairest division.

Sample Input
3
2 2 4
4
1 2 3 6

Sample Output
0
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常