02 2012 档案

摘要:http://poj.org/problem?id=3083题意:迷宫问题,求从进入点到出口,分别按靠左边,右边和最短距离到达出口所学要的步数;思路:用dfs求得靠左靠右走到达出口的步数,用bfs求最短最少到达出口的步数;代码:View Code #include <cstdio>#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <queue>using namespace std;int xx[6] = 阅读全文
posted @ 2012-02-29 22:04 LT-blogs 阅读(268) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1573简单的搜索题就不说了;因为"whether or not the number before it is 1"wrong了两次;啊!!代码:View Code #include <cstdio>#include <iostream>#include <cstring>#include <algorithm>using namespace std;bool ok = 0;void print1(int n){ printf("%d step(s) to exi 阅读全文
posted @ 2012-02-26 22:14 LT-blogs 阅读(156) 评论(0) 推荐(0)
摘要:http://acm.sdut.edu.cn/web/problem.php?action=showproblem&problemid=2389题意:判断表达式是否成立;精度要求非常高;代码:View Code #include <cstdio>#include <iostream>#include <cstring>#include <cstdlib>#include <algorithm>using namespace std;struct node{ char str[25]; double data;}link[55] 阅读全文
posted @ 2012-02-26 20:52 LT-blogs 阅读(193) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2632题意:判断机器人在行走的过程中的状况;思路:简单的模拟题,就是有点麻烦;代码:View Code #include <cstdio>#include <iostream>#include <algorithm>#include <cstdlib>#include <cstring>using namespace std;struct node{ int x; int y; int ford;}link[110];int x = 0;int y = 0;int visit[11 阅读全文
posted @ 2012-02-26 11:04 LT-blogs 阅读(167) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3295题意:判断一个表达式的值是否都为1,p, q, r, s, and t 为取值为true或false的元素,K, A, N, C, E则为对应的运算法则;思路:从后往前递推,并且要尝试所有的取值可能;代码:View Code #include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cstdlib>#include <stack>using namespa 阅读全文
posted @ 2012-02-25 19:23 LT-blogs 阅读(185) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1328题意:在一个海岸线上按一些雷达,是雷达可以覆盖海面的小岛,问最少安装多少雷达;思路:快拍+贪心;代码:View Code #include <stdio.h>#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <string.h>#include <cmath>using namespace std;struct node{ double 阅读全文
posted @ 2012-02-25 09:06 LT-blogs 阅读(162) 评论(0) 推荐(0)
摘要:题意和2965差不多,思路也是一样的:链接:2965代码:View Code #include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int s[16] ={ 0xc800,0xe400,0x7200,0x3100, 0x8c80,0x4e40,0x2720,0x1310, 0x08c8,0x04c4,0x0272,0x0131, 0x008c,0x004e,0x0027,0x0013};int result = 1 阅读全文
posted @ 2012-02-23 20:30 LT-blogs 阅读(162) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2965 位运算+搜索题意:将下图这样的图案都变成减号,规则每次改变一个,这一个的行和列都会发生转换;思路:总共有2^16的情况,全部都搜一遍,用位运算一次改变一行和一列;-+-----------+--搜索题解:View Code #include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int result = 17;int path = 0;int s[16] 阅读全文
posted @ 2012-02-23 20:00 LT-blogs 阅读(152) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2196题意:在一个每条边都有权值的树中,求每个顶点能走的最大距离;思路:两次dfs,以1为根结点,一次从叶子到根结点,求出最远距离和次远距离。另一次从根进行dfs.(res[]为经过父节点能走最长距离)代码:View Code #include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <vector>#define sum 10010using 阅读全文
posted @ 2012-02-21 21:56 LT-blogs 阅读(148) 评论(0) 推荐(0)