上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 16 下一页
摘要: View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<map> 6 7 using namespace std; 8 9 map<string,string>entry;10 map<string,string>::iterator location,pos;11 int main()12 {13 14 char line[30];15 char english[1 阅读全文
posted @ 2012-04-26 15:23 zhongya 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 解题思路:1 如果图中所有的点连通且度都为偶数则可以一笔画成。 2 如果图中有不超过2个点的度为奇数则可以一笔画。 3做法显然先通DFS判断图是否连通过,然后在判断图中奇数点度的个数即可。 View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<iostream> 5 #define N 1010 6 7 using namespace std; 8 9 int G[N][N], vis[N], num[N];10 int P, Q, ok;1 阅读全文
posted @ 2012-04-25 22:25 zhongya 阅读(178) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #define N 1000001 5 6 char s[N]; 7 int main() 8 { 9 int i, j, len,ok;10 11 while(scanf("%s",s)!=EOF && strcmp(s,"."))12 {13 len = strlen(s);14 for(i=1; i<=len; i++)15 {16 ... 阅读全文
posted @ 2012-04-25 08:33 zhongya 阅读(241) 评论(0) 推荐(1) 编辑
摘要: View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #include<queue> 4 #include<iostream> 5 #include<cstring> 6 7 using namespace std; 8 9 typedef struct 10 { 11 int x, y; 12 int step; 13 }Point; 14 15 priority_queue<Point> q; 16 bool operator<(Point a, Point b) 阅读全文
posted @ 2012-04-24 21:18 zhongya 阅读(132) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 int main() 6 { 7 int cell, i, n, j, ncases; 8 int a[101], k; 9 10 scanf("%d",&ncases); 11 for(i=1; i<=ncases; i++)12 {13 scanf("%d",&cell);14 memset(a, 0, sizeof(a)); 15 for(j 阅读全文
posted @ 2012-04-21 23:24 zhongya 阅读(192) 评论(0) 推荐(0) 编辑
摘要: PE了几次,还好及时地发现,最后一句话没好好理解,原来空行还可以这么弄View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 #define N 101 6 7 int father[N], citys; 8 double x[N], y[N], dis_sum; 9 typedef struct10 {11 int x,y; 12 double w;13 }edge;14 edge e[N*N+1];15 16 in 阅读全文
posted @ 2012-04-20 20:52 zhongya 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目意思很简单计算出所修电线的最小值,很明显Kruskal算法比Prim算法要简单。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 #define N 505 6 7 int father[N],n,row,dis_sum; 8 typedef struct 9 {10 int x,y;11 int w;12 }edge;13 edge e[N*N/2];14 int cmp(const void *a,con 阅读全文
posted @ 2012-04-20 20:48 zhongya 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 题目的本意应该是叫你求出最小生成树的最大边,和边的个数,最后把每条边的连接情况打印出来。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<math.h> 5 #define N 15001 6 7 int father[1001];//按照模板敲的 8 int p[N], n, m; 9 typedef struct 10 {11 int x, y;12 int w; 13 }edge;14 edge e[N];15 16 int 阅读全文
posted @ 2012-04-19 23:29 zhongya 阅读(175) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 5 int cmp(const void *a,const void *b)//这里要用double貌似用int不行 6 { 7 return *(double *)a > *(double *)b ? 1 : -1; 8 } 9 10 int main()11 {12 int i, n, ncases;13 double total; 14 double weight[101];15 16 while( .. 阅读全文
posted @ 2012-04-19 23:22 zhongya 阅读(293) 评论(0) 推荐(1) 编辑
摘要: 此算法在POJ上跑超时了,用了3s+;具体的思路和Prim算法一样View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #define N 755 5 6 int rank[N],father[N]; 7 int dis_sum, x[N], y[N]; 8 typedef struct 9 {10 int x, y;11 int w; 12 }edge;13 edge e[N*N];14 15 int cmp(const void *a,const void *b 阅读全文
posted @ 2012-04-19 18:51 zhongya 阅读(253) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 16 下一页