
背包问题
燑
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Piggy-Bank
Piggy-Bank在 ACM 能够开展之前,必须准备预算,并获得必要的财力支持。该活动的主要收入来自于 Irreversibly Bound Money(IBM)。思路很简单。任何时候,某位 ACM会员有少量的钱时,他将所有的硬币投入到小猪储钱罐中。这个过程不可逆,因为只有把小猪储钱罐打碎才能取出硬币。在足够长的时间之后,小猪储钱罐中有了足够的现金,用于支付ACM 活动所需的花费。但...原创 2019-07-31 21:14:40 · 136 阅读 · 0 评论 -
CD 路径记忆
You have a long drive by car ahead. You have a tape recorder, butunfortunately your best music is on CDs. You need to have it on tapesso the problem to solve is: you have a tape N minutes long. How...原创 2019-07-31 21:03:12 · 195 阅读 · 0 评论 -
背包问题汇总
01背包问题:无优化:for(int i=1;i<=n;i++){ for(int c=0;c<=m;c++) { f[i][c]=f[i-1][c]; if(c>=w[i]) f[i][c]=max(f[i][c],f[i-1][c-w[i]]+v[i]); }}一维数组优化:for(int ...原创 2019-07-30 17:41:25 · 126 阅读 · 0 评论 -
The King’s Ups and Downs
The King’s Ups and DownsThe king has guards of all different heights. Rather than line them up in increasing or decreasing height order, he wants to line them up so each guard is either shorter than...转载 2019-07-30 15:08:58 · 176 阅读 · 0 评论 -
钱币兑换问题
钱币兑换问题在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input293412553Sample Output71883113137761解题思路:外层循环从1到3,代表三种硬币,内层循环j代表的是钱数。当i=...原创 2019-07-29 20:32:43 · 1113 阅读 · 0 评论