随笔分类 - 编程
摘要:#include<iostream>#include<string>using namespace std;#define MAX_CHILD 100class TreeNode{public: string myNum; int childCount; int level; string*chil
阅读全文
posted @ 2016-09-23 18:03
narcissuscyn
摘要:#include<string.h>#include<fstream>#include <iostream>#include<queue>using namespace std;const int MAXN=500;const int INF=0xfffff; struct City{public:
阅读全文
摘要:对于物体可分割的背包问题,要获得最大的利益,我们可以选择贪心方法;而对于不可分割的问题,我们将使用动态规划的方法来解决。 1.首先回忆一下动态规划的知识: 2.0/1背包问题(对于有n个物品,容量为M的背包,每个物品或者取或者不取,即xi取0或1;要使放入背包物体的效益和最大!) 极大化 ∑ pix
阅读全文
摘要:/**1.求拓扑排序的序列2.求关键路径:广域网成整个工程所需的时间取决于从源点到汇点的最长路径长度。路径长度等于路径上各边的权之和。这条具有最大长度的路径就叫做关键路径(拓扑排序可以判断有向图是否有环)(并查集可以判断无向图是否有环,若merge(..)的时候,两个节点已经在同一个连通分支时,则表
阅读全文
摘要:/** 并查集实现克鲁斯卡尔算法 输入: 6//表示有m条边 1 2 6//表示1和2之间有一条边,权值为6 2 4 1 1 4 2 1 3 1 3 5 4 4 5 3 **/ #include<iostream> #include<vector> #include<algorithm> #defi
阅读全文

浙公网安备 33010602011771号