摘要: 最基础的最小生成树,简单题。View Code 1 #include <stdio.h> 2 #include <math.h> 3 #include <stdlib.h> 4 #define D(x1,y1,x2,y2) (sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))) 5 #define N 100 6 #define M 5000 7 struct node 8 { 9 int a,b;10 double d;11 }edge[M];12 int n,m;13 double x[N],y[N];14 int p[M];15 阅读全文
posted @ 2012-04-12 22:59 BeatLJ 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 用floyd求最短路,难得的一次ACView Code 1 #include <stdio.h> 2 #define MIN(a,b) ((a)<(b)?(a):(b)) 3 #define N 20 4 #define INF 0x7fffff 5 int dist[N][N]; 6 int main() 7 { 8 int i,j,k,x,kase=0; 9 while(1)10 {11 for(i=0;i<N;i++)12 for(j=i+1;j<N;j++) dist[i][j]=dist[j][i]=INF;13... 阅读全文
posted @ 2012-04-12 22:21 BeatLJ 阅读(151) 评论(0) 推荐(0) 编辑