随笔 - 250  文章 - 3  评论 - 66  阅读 - 21万
01 2013 档案
HDU1863畅通工程(最小生成树 Kruskal)
摘要:题目链接。#include <stdio.h>#include <stdlib.h>#define MAXN 5000int v[MAXN], u[MAXN], p[101], w[MAXN], r[MAXN];int find(int x){return p[x] == x ? x : (p[x] = find(p[x]));}int comp(const void *a, const void *b){ int x = *(int *)a, y = *(int *)b; return w[x] - w[y];}int main(){ int n, m, i, s, 阅读全文
posted @ 2013-01-28 20:58 Still_Raining 阅读(215) 评论(0) 推荐(0) 编辑
1232畅通工程(并查集)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1232#include <stdio.h>#include <stdlib.h>#define MAXN 2000int v[MAXN], u[MAXN], p[MAXN];int icount;int find_f(int x){return p[x] == x ? x : (p[x]=find_f(p[x]));}int main(){ int n, m, i; while(scanf("%d", &n) == 1 && n != 0){ 阅读全文
posted @ 2013-01-28 20:09 Still_Raining 阅读(214) 评论(0) 推荐(0) 编辑
HDU1233还是畅通工程(最小生成树 Kruskal算法)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1233//结构体做法#include <stdio.h>#include <stdlib.h>#include <string.h>int p[101],sum,num; //p为并查集struct edge//图的结构体{ int sv,ev,w;//起始边,终边,权值。};struct edge e[10000];//必须开到大于(n*n-1)/2,否则必然RE。。。int comp(const void *a,const void *b){ return (*(str 阅读全文
posted @ 2013-01-27 20:51 Still_Raining 阅读(840) 评论(0) 推荐(0) 编辑
表达式树
摘要:#include <stdio.h>#include <string.h>#define maxn 1000//const int maxn = 1000;int lch[maxn], rch[maxn]; char op[maxn];int nc = 0;int build_tree(char *s, int x, int y){ int i, c1 = -1, c2 = -1, p = 0; int u; if(y-x == 1){ u = ++nc; lch[u] = rch[u] = 0; op[u] = s[x]; retu... 阅读全文
posted @ 2013-01-26 17:28 Still_Raining 阅读(163) 评论(0) 推荐(0) 编辑
多段图动态规划算法的实现(DP)
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#include <limits.h>#define MAX_VERTEX_NUM 20#define MAX_VALUE_TYPE INT_MAXtypedef int VertexType;typedef struct node{ VertexType adjvex; int weight; //权值 struct node *next;}EdgeNode;typedef struct 阅读全文
posted @ 2013-01-16 19:35 Still_Raining 阅读(3288) 评论(0) 推荐(0) 编辑
图(邻接表--链表和边表)
摘要:最新版的请看本博客图的三种存储方式。//邻接表 链表#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#include <limits.h>#define MAX_VERTEX_NUM 20typedef int VertexType;typedef struct node{ VertexType adjvex; int weight; //权值 struct node *next;}EdgeNode;typedef struct vno 阅读全文
posted @ 2013-01-16 14:34 Still_Raining 阅读(3348) 评论(0) 推荐(0) 编辑
图(邻接矩阵)
摘要:最新版的请看本博客图的三种存储方式。#include <cstdio>#include <cstdlib>#include <cstring>#include <conio.h>#include <limits.h>#define MAXN 256#define INFINITY INT_MAX#define MAX_VERTEX_NUM 20#define OK 1typedef int VRType;typedef int InfoType;typedef int VertexType;typedef int Status;typ 阅读全文
posted @ 2013-01-15 17:00 Still_Raining 阅读(328) 评论(0) 推荐(0) 编辑
BFS
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAXN 100int maze[MAXN][MAXN];int vis[MAXN][MAXN];int queue[MAXN*MAXN]; //队列int fa[MAXN][MAXN]; // 父结点int dx[]={0,0,-1,1};int dy[]={-1,1,0,0};int n,m; //n为行 m为列void bfs(int x, int y){ int front, rear, u, d; front = rear 阅读全文
posted @ 2013-01-13 11:51 Still_Raining 阅读(198) 评论(0) 推荐(0) 编辑
UVA 10106 - Product
摘要:10106 - ProductThe ProblemThe problem is to multiply two integers X, Y. (0<=X,Y<10250)The InputThe input will consist of a set of pairs of lines. Each line in pair contains one multiplyer.The OutputFor each input pair of lines the output line should consist one integer the product.Sample Input 阅读全文
posted @ 2013-01-12 16:46 Still_Raining 阅读(187) 评论(0) 推荐(0) 编辑
Integer Inquiry
摘要:Integer Inquiry地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=97&problem=365&mosmsg=Submission+received+with+ID+11121758One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers 阅读全文
posted @ 2013-01-10 20:47 Still_Raining 阅读(186) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示