随笔分类 -  背包问题

魔兽争霸3之冰封王座
摘要:魔兽争霸3之冰封王座Time Limit:1000MSMemory Limit:65535KBSubmissions:47Accepted:21Description魔兽争霸是游侠UFO最喜欢玩的游戏之一,某天下午游侠UFO在网上和某人厮杀,战争进入了胶着状态,如何把手上的资源有效地转化成战斗力成了困扰游侠UFO的一个问题。现在游侠UFO手上有一大笔钱V,而他所选的Undead族有N个兵种,是造一大堆食尸鬼还是一群冰龙呢?这是你需要帮助游侠UFO解决的问题。我们知道,每个兵种都有不同的造价和作战能力,假设第i个兵种造价为v[i],作战能力为w[i]。显然为了能得到更高的获胜概率,我们需要在有限 阅读全文

posted @ 2013-03-08 18:03 即为将军 阅读(383) 评论(0) 推荐(0)

Piggy-Bank
摘要:Piggy-BankTime Limit:1000MSMemory Limit:65535KBSubmissions:262Accepted:108DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some 阅读全文

posted @ 2013-03-06 09:56 即为将军 阅读(330) 评论(0) 推荐(0)

邮票
摘要:邮票Time Limit:1500MSMemory Limit:65535KBSubmissions:227Accepted:46Description已知一个 N 枚邮票的面值集合(如,{1 分,3 分})和一个上限 K —— 表示信封上能够贴 K 张邮票。计算从 1 到 M 的最大连续可贴出的邮资。 例如,假设有 1 分和 3 分的邮票;你最多可以贴 5 张邮票。很容易贴出 1 到 5 分的邮资(用 1 分邮票贴就行了),接下来的邮资也不难: 6 = 3 + 3 7 = 3 + 3 + 1 8 = 3 + 3 + 1 + 1 9 = 3 + 3 + 3 10 = 3 + 3 + 3 + 1 阅读全文

posted @ 2013-02-26 12:47 即为将军 阅读(293) 评论(0) 推荐(0)

Coins
摘要:CoinsTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a nearby shop. He wanted to pay th 阅读全文

posted @ 2012-08-18 23:37 即为将军 阅读(264) 评论(0) 推荐(0)

Space Elevator
摘要:Space ElevatorTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which to build the 阅读全文

posted @ 2012-08-18 22:37 即为将军 阅读(328) 评论(0) 推荐(0)

01背包问题
摘要:01背包问题:1.递归思想0- 1 背包问题如果采用递归算法来描述则非常清楚明白, 它的算法根本思想是假设用布尔函数knap( s, n) 表示n 件物品放入可容质量为s 的背包中是否有解( 当knap 函数的值为真时说明问题有解,其值为假时无解) . 我们可以通过输入s 和n 的值, 根据它们的值可分为以下几种情况讨论:( 1) 当s= 0时可知问题有解, 即函数knap( s, n) 的值为true; ( 2) 当s< 0 时这时不可能, 所以函数值为false; ( 3) 当输入的s> 0 且n< 1 时即总物品的件数不足1, 这时函数值为false, 只有s> 阅读全文

posted @ 2012-05-08 09:40 即为将军 阅读(50554) 评论(2) 推荐(11)

导航