摘要: Bone Collector最基本的01背包 两种实现都要掌握的很熟练!二维数组实现01背包: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define LL long long10 using namespace std;11 12 int dp[1010][1010];13 14 void run()15 {16 int p, n, m;17 int a[1010], b[1010];18 scanf("%d",... 阅读全文
posted @ 2013-11-06 20:03 GLSilence 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 饭卡思路:先把最贵的一个拿出来,剩下的用背包求出最优解,用5元去买最贵的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define LL long long10 using namespace std;11 12 void run()13 {14 int n, m;15 int a[1010], dp[1010];16 while(~scanf("%d", &n) && n)17 {18 in... 阅读全文
posted @ 2013-11-06 16:56 GLSilence 阅读(189) 评论(0) 推荐(0) 编辑
摘要: The Twin TowersLCS水题,就是题读的时候有点费劲。 我英语是渣渣- -! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define LL long long10 using namespace std;11 12 void run()13 {14 int n, m;15 int dp[110][110];16 int a[110], b[110];17 int cnt = 0;18 w... 阅读全文
posted @ 2013-11-06 09:40 GLSilence 阅读(160) 评论(0) 推荐(0) 编辑