- 博客(6)
- 资源 (1)
- 收藏
- 关注
转载 背包问题--代码
背包问题(空间优化)经典代码题目<br />有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路<br />这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。<br />用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:<br />f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}<br />这个方程非常重要,基本上所有跟背
2011-05-20 17:39:00
332
转载 背包问题--代码
背包问题(空间优化)经典代码题目<br />有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路<br />这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。<br />用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:<br />f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}<br />这个方程非常重要,基本上所有跟背
2011-05-20 17:38:00
362
原创 bwt
<br />#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <malloc.h>#include <sys/stat.h>#include <sys/types.h>#include <errno.h>#include <fcntl.h>/*xiaolai 2011-5-09 I pay 8 hours to write ,so bad ...
2011-05-13 21:53:00
514
原创 bwt
<br />#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <malloc.h>#include <sys/stat.h>#include <sys/types.h>#include <errno.h>#include <fcntl.h>/*xiaolai 2011-5-09 I pay 8 hours to write ,so bad ...
2011-05-13 21:53:00
344
原创 深入探究二叉树(c)--(2)
<br />文件tree.c<br />//tree.c xiaolai 2011-5-13#include <string.h>#include <stdio.h>#include <stdlib.h>#include "Tree.h"typedef struct pair { Node * parent; Node * child; } Pair;static Node * MakeNode( const Item * pi);static bool ToLef
2011-05-13 21:48:00
379
原创 深入探究二叉树(c)--(1)
<br />#ifndef _TREE_H_#define _TREE_H_//文件头,#include <stdbool.h>typedef struct item{ char petname[20]; char petkind[20];}Item;#define MAXITEM 10typedef struct node { Item item; struct node *left; struct node * r
2011-05-13 21:44:00
210
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人