- 浏览: 741061 次
- 性别:
- 来自: 上海
-
最新评论
-
SSailYang:
居然还有姑娘爱好法律史,哈哈
米兰达警告 -
anttu:
打开i此页面 耗我1G多内存,尼玛你是不是置病毒了?
[十月往昔]——Linux内核中的内存管理浅谈 -
wangyutian2011:
大哥,你是怎么装上去的啊?、
能不能将你的安装过程讲解一二?
...
今天晚上终于在虚拟机上把VxWorks建好了。 -
iwindyforest:
道理是这样, 可是如果你面临转型呢?你为了发展, 或者更明确的 ...
为什么他的技术平平却是我的顶头上司?想了很长时间,深有感触 -
dwbin:
我始终觉着做任何事情都是靠头脑而不是大道理堆出来的。
为什么他的技术平平却是我的顶头上司?想了很长时间,深有感触
文章列表
每对顶点间的最短距离 稀疏有向图Johnson算法 C++实现
// 稀疏有向图Johnson算法.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define Infinity 65535
#define MAX 100
using namespace std;
//边尾节点结构体
struct edgeNode
{
int no;//节点序号
int weight; //此边权值 ...
- 2011-11-16 16:42
- 浏览 1596
- 评论(0)
// 每对顶点间的最短距离Floyd_Warshall算法.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define Infinity 65535
#define NIL 65535
using namespace std;
//d
int d1[MAX][MAX];
int d2[MAX][MAX];
//用来存储边的权值,即有向图的邻接矩阵
i ...
- 2011-11-14 22:28
- 浏览 1010
- 评论(0)
// 每对顶点间的最短路径.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define Infinity 65535
using namespace std;
//L2[i][j]存储L1[i][j]*Lij
int L1[MAX][MAX];
int L2[MAX][MAX];
//用来存储边的权值,即有向图的邻接矩阵
int w[MAX][MAX] ...
- 2011-11-14 22:20
- 浏览 542
- 评论(0)
// 每对顶点间的最短路径.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define Infinity 65535
using namespace std;
//
int L1[MAX][MAX];
int L2[MAX][MAX];
//用来存储边的权值,即有向图的邻接矩阵
int w[MAX][MAX];
//初始化,把w[i][j]赋给L1[i] ...
- 2011-11-11 16:47
- 浏览 578
- 评论(0)
ACM食物链
Description
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述:
第一种说法是"1 X Y",表示X和Y是同类。
第二种说法是"2 X Y",表示X吃Y。
此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真话。
1) 当前的话与前面的某 ...
- 2011-11-11 16:28
- 浏览 679
- 评论(0)
ACM黑箱子
Description
有一个黑箱子,里面会按升序存储整数,你可以对黑箱子下达下面的指令:
a. ADD n 将n加入黑箱子
b. Get 获得一个数,这个数在黑箱子里的序号(从0开始计数)是Get的出现次数。
黑箱子中最初存了一个数0,现给你一个操作序列,要你输出Get命令时获的那个数。
输入:
每行是一个命令,如果命令是”ADD”,则后面空一格,有一个整数。输入时保证GET命令不会越界
输出:
每行输出一个整数,整数为对应Get获得值。
Sample Input
ADD 3
GET
ADD 1
GET
ADD -4
ADD 2
ADD 8
...
- 2011-11-11 16:24
- 浏览 635
- 评论(0)
差分约束:线性规划矩阵A的每一行包含一个1与一个-1,其他元素为0.因此,由Ax<=b给出的约束条件是m个差分约束集合,其中包含n个未知元。每个约束条件为不等式:
xj-xi<=bk
其中1<=i,j<=n,i<=k<=m
解决方法:把n个未知元看成n的有向图的顶点,xj-xi<=bk表示顶点j到顶点i长度为bk的有向线段。再添加一个v0顶点,与v0到其余顶点的有向线段,长度为0。(如下图)
可以证明 xi=β(v0,vi)(β(v0,vi)为顶点0到顶点i的最短路径长度)。所以就可以利用Bellman_Ford算求单源最短路径(不能用Di ...
- 2011-11-10 02:24
- 浏览 456
- 评论(0)
// 单源最短路径Bellman_Ford算法.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define Infinity 65535
typedef int WeiType;
using namespace std;
struct edgeNode
{
int no; //边尾端的序号
char info; //边端的名称
WeiType wei ...
- 2011-11-09 22:27
- 浏览 651
- 评论(0)
// 单源最短路径Dijkstra算法实现.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 200
#define Infinity 65535
using namespace std;
//边尾节点信息结构体
struct edgeNode
{
int no; //尾接点序号
int cost; //边权值
edgeNode *next; //其下一条邻接边尾 ...
- 2011-11-09 20:26
- 浏览 5609
- 评论(0)
ACM唯一的最小生成树
Description
求一个非负权边的无向连通图的最小生成树,如果这个无向图存在两个或两个以上的最小生成树,就输出Not Unique,否则输出最小生成树的边的权值和。
输入:
第一行是一个整数K,表示有多少个测试用例,以后每个测试用例占m+1行。每个测试用例的第一行为两个整数n,m(3<=n<=100),表示图的顶点数和边数,从第二行开始每行为三个整数i,j,w,表示从i到j顶点的权值。
输出:
每行输出一个测试用例的结果。如果这个无向图存在两个或两个以上的最小生成树,就输出Not Unique,否则输出最小生成树的边的权值和。
Samp ...
- 2011-11-08 22:29
- 浏览 653
- 评论(0)
// Prim算法实现(采用邻接表存储).cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define Infinity 65535
typedef int WeiType;
using namespace std;
struct edgeNode
{
int no; //边端的序号
char i ...
- 2011-11-08 20:00
- 浏览 4521
- 评论(0)
// Kruskal算法实现.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
typedef int WeiType;
using namespace std;
//
struct Edge
{
int no; //边的序号
int x; //端点1序号
int y; // 端点2序号
WeiType weight; //权值
bool select ...
- 2011-11-08 18:06
- 浏览 752
- 评论(0)
// 强连通分支(邻接表存储).cpp : Defines the entry point for the console application.
//通过二次利用深度优先搜索访问节点,每次的深度优先搜索操作不同
#include "stdafx.h"
#include<iostream>
#define MAX 100
using namespace std;
//深度搜索访问节点层次标志枚举变量
enum Color{white,gray,black};
//边端点结构体
struct edgeNode
{
int no; //边尾 ...
- 2011-11-07 17:32
- 浏览 1053
- 评论(0)
// 有向无回路图拓扑排序.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
using namespace std;
enum Color{white,gray,black};
struct edgeNode
{
int no; //边尾端的序号
char info; //边端的名称
struct edgeNode * next; //下一个
};
str ...
- 2011-11-05 23:24
- 浏览 631
- 评论(0)
// 无向图的一节点到另一节点的最短路径(边数最少的路径)(采用邻接表存储).cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#define MAX 100
#define MAXQ 50
using namespace std;
struct edgeNode
{
int no; //边端的序号
char info; //边端的名称
struct edgeNode * next; //下一 ...
- 2011-11-05 20:20
- 浏览 1595
- 评论(0)