• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
mengxm
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 3 4 5 6 7 8 下一页
2011年6月9日
poj1028
摘要: http://poj.org/problem?id=1028一道栈模拟题目,要注意地方只有一个,就是当在栈中某处访问新地址后,不能再访问栈此处之后的地址,只能访问之前的。 1 #include<stdio.h> 2 char str[200][71]={"http://www.acm.org/"}; 3 int point=0,end=0; 4 void forword() 5 { 6 if(point>=end) printf("Ignored\n"); 7 else printf("%s\n",str[++poi 阅读全文
posted @ 2011-06-09 23:24 mengxm 阅读(503) 评论(1) 推荐(1)
poj1008
摘要: http://poj.org/problem?id=1008一道日历转换题,要注意%和/符号的运用,还要注意一年的最后一天在/运算符的作用下算作第二年,给数据:4. uayet 259正解是 13 ahau 364而不是13 ahau 365 1 #include<stdio.h> 2 #include<string.h> 3 char month_Haab[19][20]={"pop","no","zip","zotz","tzec","xul",& 阅读全文
posted @ 2011-06-09 23:05 mengxm 阅读(612) 评论(0) 推荐(0)
2011年6月7日
HDU2577
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2577此题为本人第一次自主分析动态规划。对于每个字母之前的字母有两种状态 1.tab开启 2.tab没有开启,有数组分别记录两种状态下的最短时间,接下来状态转移方程:0代表没开,1代表开了,对当前字母分类小写字母: timer[i+1][0]=min(timer[i][0]+1,timer[i][1]+2); timer[i+1][1]=min(timer[i][0]+2,timer[i][1]+2);大写字母: timer[i+1][0]=min(timer[i][0]+2,timer[i][1]+2); 阅读全文
posted @ 2011-06-07 17:21 mengxm 阅读(652) 评论(0) 推荐(0)
2011年6月6日
poj2488
摘要: http://poj.org/problem?id=2488问从8*8的矩阵上某一点,以某一方向两格,而另一个方向一格的方式前进,出发能否遍历整个矩阵,若能则输出遍历的路线。采用深搜遍历,但要注意此题有一个隐性要求遍历路线要字典序最小。 1 #include<stdio.h> 2 int dir[8][2]={-2,-1,-2,1,-1,-2,-1,2,1,-2,1,2,2,-1,2,1}; /*注意此处的数组数据, 3 为了保证每次的探索都是 4 符合字典序的*/ 5 int g,a,b; 6 int vist[26][26],path[26][2]; 7 void find(i 阅读全文
posted @ 2011-06-06 01:23 mengxm 阅读(1259) 评论(0) 推荐(0)
poj2421
摘要: http://poj.org/problem?id=2421此题主要问题在于某些路径已经存在,在此基础上求解构成最小生成树的剩余边的总和可以采用kruskal中的并查集思想将已存在的路径形成集合然后接着用kruskal求解剩余边 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 int map[1001][1001],father[1001]; 5 struct line 6 { 7 int begin; 8 int end; 9 int lenth;10 };11 line amoun 阅读全文
posted @ 2011-06-06 01:12 mengxm 阅读(589) 评论(0) 推荐(0)
poj2075
摘要: http://poj.org/problem?id=2075此题求解最小生成树的权值,此题麻烦之处在于字符串的判断 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 char **name; 6 struct line 7 { 8 int begin; 9 int end;10 float lenth;11 };12 line * amount;13 float sumofcost;14 int * father;15 int num 阅读全文
posted @ 2011-06-06 01:07 mengxm 阅读(236) 评论(0) 推荐(0)
poj2395
摘要: http://poj.org/problem?id=2395此题题意为求解最小生成树的最大边 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 #define max(a,b) a>b?a:b 5 struct line 6 { 7 int begin; 8 int end; 9 int lenth;10 };11 line * amount;12 int * father;13 int numofnode,numofline;14 int i,j,a,b,c;15 int fin 阅读全文
posted @ 2011-06-06 01:01 mengxm 阅读(289) 评论(0) 推荐(0)
poj2377
摘要: http://poj.org/problem?id=2377题意为给你一幅图,让你判断图有无最大支撑树,若有则求解图的最大支撑树,若无则输出-1由于题目给的数据方式用kruskal比较方便,然后我们用已采纳的边数来断定图是否连通,边数=节点数-1 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 struct line 5 { 6 int begin; 7 int end; 8 int lenth; 9 };10 line * amount;11 int * father;12 int 阅读全文
posted @ 2011-06-06 00:54 mengxm 阅读(238) 评论(0) 推荐(0)
poj1251
摘要: http://poj.org/problem?id=1251此题一看就知是最小生成树,由于数据量很小,输入的数据形式也没有那一种比较方便,所以prim和kruskal都可以下面给出kruskal代码 1 #include<stdio.h> 2 #include<iostream> 3 #include<algorithm> 4 using namespace std; 5 struct line 6 { 7 int begin; 8 int end; 9 int lenth;10 };11 line num[100];12 int amount,sumofl 阅读全文
posted @ 2011-06-06 00:47 mengxm 阅读(415) 评论(0) 推荐(0)
poj2485
摘要: http://poj.org/problem?id=2485此题主要是题意要读懂!!尤其是最后一句话,For each test case, you should output a line contains an integer, which is the length of the longest road to be built such that all the villages are connected, and this value is minimum.逐个词翻译,就是求所有支撑树中最大边最小的支撑树的最大边,理解题意后,就会发现求解的就是最小生成树的最大边并且此题一看就是用p 阅读全文
posted @ 2011-06-06 00:40 mengxm 阅读(496) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3