上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 31 下一页
摘要: Q: 既是多重背包, 还是找零问题, 怎么处理?A: 题意理解有误, 店主支付的硬币没有限制, 不占额度, 所以此题不比 1252 难多少DescriptionFarmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coins he uses to pay plu 阅读全文
posted @ 2013-12-08 16:52 SangS 阅读(499) 评论(0) 推荐(0) 编辑
摘要: Q: 额外添加了最大高度限制, 需要根据 alt 对数据进行预处理么?A: 是的, 需要根据 alt 对数组排序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 #include using namespace std;int K;const int MAXN = 40010;bool dp[40010];int h[MAXN], a[MAXN];int V 阅读全文
posted @ 2013-12-08 15:20 SangS 阅读(427) 评论(0) 推荐(0) 编辑
摘要: Q: 倍增优化后, 还是有重复的元素, 怎么办A: 假定重复的元素比较少, 不用考虑DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just split the co 阅读全文
posted @ 2013-12-08 11:56 SangS 阅读(326) 评论(0) 推荐(0) 编辑
摘要: DescriptionBefore 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 ACM member has any small money, he takes all the coins and throws them in 阅读全文
posted @ 2013-12-08 11:06 SangS 阅读(297) 评论(0) 推荐(0) 编辑
摘要: Q: 每年一个完全背包?A: YESDescriptionJohn never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only inheritor.John did not need that much money for the moment. But he re 阅读全文
posted @ 2013-12-08 10:48 SangS 阅读(265) 评论(0) 推荐(0) 编辑
摘要: Q: 01背包最后返回什么 dp[v], v 是多少?A: 普通01背包需要遍历, 从大到小. 但此题因为物品的总重量必定大于背包容量, 所以直接返回 dp[V] 即可update 2014年3月14日11:22:551. 几个月后, 感觉返回的不应该是 dp[V], 二是 dp[0...V] 中的最大值DescriptionDearboy was so busy recently that now he has piles of clothes to wash. Luckily, he has a beautiful and hard-working girlfriend to help h 阅读全文
posted @ 2013-12-08 10:06 SangS 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Q: dp 数组应该怎么设置?A: dp[i][j] 表示前 i 件物品放入天平后形成平衡度为 j 的方案数题意:有一个天平, 天平的两侧可以挂上重物, 给定 C 个钩子和G个秤砣.2 4-2 33 4 5 8C = -2, G = 3, 那么2*(3+4+5)=3*(8); 2*(4+8)=3*(3+5)共有两种可行的方案, 那么结果就是2DescriptionGigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other or 阅读全文
posted @ 2013-12-07 21:52 SangS 阅读(303) 评论(0) 推荐(0) 编辑
摘要: Q: 如何判断几件物品能否被 2 辆车一次拉走?A: DP 问题. 先 dp 求解第一辆车能够装下的最大的重量, 然后计算剩下的重量之和是否小于第二辆车的 capacity, 若小于, 这 OK.DescriptionEmma and Eric are moving to their new house they bought after returning from their honeymoon. Fortunately, they have a few friends helping them relocate. To move the furniture, they only have 阅读全文
posted @ 2013-12-07 21:09 SangS 阅读(377) 评论(0) 推荐(0) 编辑
摘要: 题意:猜数字, 给定 G, L, G 表示可以猜的次数, 每猜一次, G减一, 假如猜的 number 大于 target, L 还需减一, 当 L == -1 或者 G==0 时, 若还没猜中, 则失败思路:1. 举例子 当 G = 3, L = 0 时, 只能从 1 向上猜, 最大的数字是 3 当 G = 2, L = 1 时, 不必从 1 猜起, 假设猜 k, 假如小了, 状态变成 (1,0), 由 (1) 得到的规律知, k 不能大于 2; 假如大了, 那么状态变成 (1,1), 还有一次机会, 可见, (2,1) 等于 3 当 (3,1) 时, 仍然假设猜 K, 假如小了,... 阅读全文
posted @ 2013-12-07 18:54 SangS 阅读(326) 评论(0) 推荐(0) 编辑
摘要: discuss 看到有人讲完全背包可以过, 假如我自己做的话, 也只能想到完全背包了思路:1. 当 n 为奇数时, f[n] = f[n-1], 因为只需在所有的序列前添加一个 1 即可, 所有的序列同时延迟 1 位, 不会出现重复 若是这个 1 和其他的1组成 2 而不是放在首位, 怎么办? 不会这样, 因为这个序列肯定已经存在了 证明, 假设sum(s1) = 2*k, s1内部某个1加1得到 s2, 则 sum(s2) = 2*k+1, s2 的首位仍然肯定是1, 那么 s2 也可以通过 s3 延长而来, 所以必然已经存在了 2. 当 n 为偶数时, 分为两种情况 某个序列首位... 阅读全文
posted @ 2013-12-07 15:56 SangS 阅读(1916) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 31 下一页