b606. Add All 您所在的位置:网站首页 b606e飞机 b606. Add All

b606. Add All

2024-06-30 05:16| 来源: 网络整理| 查看: 265

給你一個數列, 找出數列上數字相加時最好的成本是多少

The problem name reflects your task; just add a set of numbers. But you may feel yourselves condescended, to write a program just to add a set of numbers. Such a problem will simply question your erudition. So, let us add some flavor of ingenuity to it.

Addition operation requires cost now, and the cost is the summation of those two tobe added. So, to add 1 and 10, you need a cost of 11. If you want to add 1, 2 and 3.

There are three ways: 

(1) 1 + 2 = 3, cost = 3; 3 + 3 = 6, cost = 6; Total = 9(2) 1 + 3 = 4, cost = 4; 4 + 2 = 6, cost = 6; Total = 10(3) 2 + 3 = 5, cost = 5; 5 + 1 = 6, cost = 6; Total = 11

Your task is write a program to add a set of integers so that the cost is minimized.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有