博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年9月10日

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4021先确保两个表格的0都移到4*4内(而不是在八个顶点之一上),输出N的条件是: 1.八个顶点完全一样。 2.内部的4*4可以拼成。参考:http://topic.csdn.net/u/20081019/22/719a3ab7-359d-4d23-8677-07ec0d7b2289.htmlView Code #include <stdio.h>#include <math.h>#include <algorithm>using namespace std;int 阅读全文

posted @ 2011-09-10 21:35 紫华弦筝 阅读(377) 评论(2) 推荐(1) 编辑

2011年9月9日

摘要: 题目:http://poj.org/problem?id=1228题意:给定一些点,求能否确定一个凸包。如果在这些点中求出的凸包的每一条边都至少有三个点(包括顶点),则这个凸包是确定的。 注意一条直线或点数n<5时应输出NO。View Code #include <stdio.h>#include <math.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;const double eps = 1e-8;const d 阅读全文

posted @ 2011-09-09 12:39 紫华弦筝 阅读(212) 评论(0) 推荐(0) 编辑

2011年9月8日

摘要: 题目:http://poj.org/problem?id=3662题意:FJ要从1到N接电话线,电话公司可以免除K条的费用,求让需付费的电话线中的最大值在各种方案中最小的值,并输出。我用的是二分+Dijkstra+二次建图的方法:假设A是可行解,即路径上边权最大值为A,则该路径上边权大于A的边一定小于等于K条。若A不是最优解,那么必然B<A,是的路径上边权大于B的边小于等于K。于是我们可以二分答案,得到一个值X,将所有小于等于X的边变为0,大于X的边变为1。做最短路,则1到N的距离就是所用权值大于X边的条数。如果小于等于K,则是一个可行解。View Code #include<st 阅读全文

posted @ 2011-09-08 22:19 紫华弦筝 阅读(160) 评论(0) 推荐(0) 编辑

摘要: 题目:http://poj.org/problem?id=3072题意:平面上有n个点,从一点到另一点需要转向的话就需要时间,求从第一点到第n点的最短时间。注意:1、转向角度<=180度。2、计算转向角: 例如:由P1经过P2到P3 angle=fabs(atan2(p2.y-p1.y,p2.x-p1.x)【P2-P1向量的方向角】-atan2(p3.y-p2.y,p3.x-p2.x)【P3-P2向量的方向角】)3、初始时,robot是面向第n点的。View Code #include<stdio.h>#include<string.h>#include<m 阅读全文

posted @ 2011-09-08 22:12 紫华弦筝 阅读(155) 评论(0) 推荐(0) 编辑

2011年9月7日

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4007给定一些点和一个正方形,求正方形能圈住的最多点数。参考了P103的黑书。View Code #include <stdio.h>#include <algorithm>using namespace std;typedef struct{ int x, y;} point;bool cmp(point a, point b){ if (a.x == b.x) return a.y < b.y; return a.x < b.x;}bool cmp2(point 阅读全文

posted @ 2011-09-07 23:43 紫华弦筝 阅读(144) 评论(0) 推荐(0) 编辑

摘要: 题目:http://poj.org/problem?id=1264一道凸包题,求导弹射中的凸包的面积之和。View Code #include <stdio.h>#include <math.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;const double eps = 1e-8;const double pi = acos(-1.0);typedef struct{ double x, y;}cpoint;doubl 阅读全文

posted @ 2011-09-07 23:43 紫华弦筝 阅读(164) 评论(0) 推荐(0) 编辑