首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

九度OJ——1107搬水果

题目描述: 在一个果园里,小明已经将所有的水果打了下来,并按水果的不同种类分成了若干堆,小明决定把所有的水果合成一堆。每一次合并,小明可以把两堆水果合并到一起,消耗的体力等于两堆水果的重量之和。当然经过 n‐1 次合并之后,就变成一堆了。小明在合并水果时总共消耗的体力等于每次合并所耗体力之和。 假定每个水果重量都为 1,并且已知水果的种类数和每种水果的数目,你的任务是设计出合并的次序方案,使小明耗费的体力最少,并输出这个最小的体力耗费值。例如有 3 种水果,数目依次为 1,2,9。可以先将 1,2 堆合并,新堆数目为3,耗费体力为 3。然后将新堆与原先的第三堆合并得到新的堆,耗费体力为 12。所以小明总共耗费体力=3+12=15,可以证明 15 为最小的体力耗费值。 输入: 每组数据输入包括两行,第一行是一个整数 n(1<=n<=10000),表示水果的种类数,如果 n 等于 0 表示输入结束,且不用处理。第二行包含 n 个整数,用空格分隔,第 i 个整数(1<=ai<=1000)是第 i 种水果的数目。 输出: 对于每组输入,输出一个整数并换行,这个值也就是最小的体力耗费值。输入数据保证这个值小于 2^31。 样例输入: 3 9 1 2 0 样例输出: 15

01

PHP+MYSQL插入数据库的数据

insert shop_goods(gname,price,pic) values(‘apple1’,‘4881’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple2’,‘4882’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple3’,‘4883’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple4’,‘4884’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple5’,‘4885’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple6’,‘4886’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple7’,‘4887’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple8’,‘4888’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple9’,‘4889’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple10’,‘48810’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple11’,‘48811’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple12’,‘48812’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple13’,‘48813’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple14’,‘48814’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple15’,‘48815’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple16’,‘48816’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple17’,‘48817’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple18’,‘48818’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple19’,‘48819’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple20’,‘48820’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple21’,‘48821’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple22’,‘48822’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple23’,‘48823’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple24’,‘48824’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple25’,‘48825’,‘3.jpg’); insert shop_goods(gname,price,pic) values(‘apple26’,‘48826’,‘4.jpg’); insert shop_goods(gname,price,pic) values(‘apple27’,‘48827’,‘1.jpg’); insert shop_goods(gname,price,pic) values(‘apple28’,‘48828’,‘2.jpg’); insert shop_goods(gname,price,pic) values(‘apple29’,‘48829’,‘1.jpg’); insert

02
领券