编程介的小学生 2020-01-12 13:55 采纳率: 20.5%
浏览 80

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?