多重背包的可行性问题。
题意是说 一块表的价格不超过M。你有一些不同数量,也不同面额的硬币。在1-M中你能组成多少种可能。
傻逼的理解成组成不超过M的最大价值。ORZ。。。认真读题……
时间复杂度 O(M*N)
#include
#include
#include
using namespace std;
int dp[2][100005];
int n,m;
...
分类:
其他好文 时间:
2014-07-13 16:19:39
阅读次数:
172
题目链接:http://poj.org/problem?id=2000题目大意:求N天得到多少个金币,第一天得到1个,第二、三天得到2个,第四、五、六天得到3个、、、、以此类推,得到第N天的金币数。 1 #include 2 #include 3 #include 4 using namesp...
分类:
其他好文 时间:
2014-07-12 08:51:24
阅读次数:
176
Coin Change
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.
For example, if ...
分类:
其他好文 时间:
2014-07-10 21:12:39
阅读次数:
158
Square CoinsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7883Accepted Submission(s): 5332Proble...
分类:
其他好文 时间:
2014-07-02 14:49:04
阅读次数:
196
裸0/1背包,就是从各种币种里面拿来凑足N元,求最多有多种方案。用dp[i][j]表示选前i个币种凑成j的方案数量
状态转移方程: dp[i][j] = dp[i- 1][j] j = coins[i]
/*
ID:kevin_s1
PROG:money
LANG:C++
*/
#include
#include
#include
#include
#include
#i...
分类:
其他好文 时间:
2014-07-01 09:29:13
阅读次数:
209
#include
#include
#include
#include
#include
#include
#include
#include
#define inf 0x3f3f3f3f
#define ll __int64
using namespace std;
int n,m,dp[100010],a[100010],c[1010];
void pack01(int c...
分类:
其他好文 时间:
2014-06-27 08:07:53
阅读次数:
157
题目描述You are given N baskets of gold coins. The baskets are numbered from 1 to N. In all except one of the baskets, each gold coin weighs w grams. In t...
分类:
其他好文 时间:
2014-06-14 16:22:52
阅读次数:
191
1068. Find More Coins (30)Eva loves to collect
coins from all over the universe, including some other planets like Mars. One
day she visited a univers...
分类:
其他好文 时间:
2014-06-08 18:49:44
阅读次数:
432
本题使用动态规划法, 或者记忆法,加上递归法。
不加上递归法,好像很麻烦,因为我们不知道其初始值,只知道其最终值,所以只能往下递推了,这样使用记忆法就比动态规划要方便了。
使用二维表设计其递归记忆表,防止重复计算。还是十分困难的,动态规划法有时候不一定比记忆法要好。
递归记忆法的学名: top-down with memoization; Introduction to Algorithm的Dynamic programming 这章有介绍...
分类:
其他好文 时间:
2014-06-02 23:04:24
阅读次数:
397
The Game of Coins
mark:
#include"cstdio"
#include"iostream"
#include"queue"
#include"algorithm"
#include"set"
#include"queue"
#include"cmath"
#include"string.h"
#include"vector...
分类:
其他好文 时间:
2014-06-01 13:58:31
阅读次数:
196