
计算几何
iDev9
iOS Developer
展开
-
pku1265Area
题目链接:pku1265代码://3 #include using namespace std;int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b);}#define max 105struct point{ double x,y; };typedef point polygon[max]; double polygon_area(polygon p,int n){ d原创 2010-07-29 17:42:00 · 373 阅读 · 0 评论 -
pku2208pyramids
题目:pku2208题意:已知四面体的六条边长,求其体积。下面二种方法均可作为模板。代码一:先求角度,再求体积。由wanglang515 编写Memory: 176K Time: 16MS#include#includeint main(){ double a,b,c,d,e,f,v; double angle1,angle2,angle3,angle; while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EO原创 2010-08-06 13:55:00 · 405 阅读 · 0 评论 -
pku1569Myacm Triangles
<br />题目:pku1569<br /> <br />代码:计算几何(判断点是否在三角形内部 )+枚举<br />// the number of monuments: at least 4, and at most 15#include <iostream>#include <cmath>using namespace std;const double eps=1e-10;struct point{ double x,y; };typedef point tria原创 2010-08-06 14:29:00 · 387 阅读 · 0 评论 -
pku1106Transmitters
<br />题目链接:pku1106<br /> <br />题意:已知一半圆的圆心及半径,还有一些点,判断半圆中最多可有几个点。<br /> <br />本题难点在于将题意理解透彻,了解叉积的意义。<br /> <br />代码:叉积及判断点在圆内部<br /> <br />//1-150 unique point//先把到圆心距离大于半径的删除掉,枚举每个点所在的直径,//统计一下在其下方的点的个数,取最大值#include <iostream>#include <cmath>u原创 2010-08-07 21:11:00 · 438 阅读 · 0 评论 -
pku1319Pipe Fitters
<br />题目:pku1319<br /> <br />解法:斜放n层高为 sqrt(3.0)/2*(n-1)+1<br /> <br />代码:<br /> <br />// All dimensions will be less than 128. // If the pattern doesn't matter, that is the same number of pipes can be packed // with either a grid or skew pattern, the原创 2010-08-08 22:13:00 · 503 阅读 · 0 评论 -
pku1556The Doors
题目:pku1556方法:直线相交判断+dijkstra算法代码://0 #include #includeusing namespace std;//Dijkstra算法模板开始//==========================================原创 2010-07-31 13:19:00 · 378 阅读 · 0 评论 -
tzc1448 两圆相交面积
题目:tzc1448方法:计算几何思想:本题是给出两圆的圆心和半径,要求两圆相交的面积。假设圆心为a,b,交点为c,d,而 由两圆心组成的线段和 交点与圆心组成的两条半径共同构成的三角形 的三边都可以得到,从而求出两半径与圆心组成的线段的角度,最后,用圆弧原创 2011-08-02 14:42:39 · 2175 阅读 · 0 评论 -
hdu1140 War on Weather
题目链接:hdu1140 pku2660方法:计算几何思想:本题是给定k颗卫星,m个地点,看这卫星能够射到几个地方。首先将卫星的坐标保存,然后每读入一个地点,就判断能否有卫星能够发射到本地。由于地点均在地球表面,在判断某卫星能否到达本地时,可以通过卫星所原创 2011-08-02 18:50:35 · 1322 阅读 · 0 评论 -
pku1066 Treasure Hunt
http://acm.pku.edu.cn/JudgeOnline/problem?id=1066代码一:线段相交+枚举//0 #include#include#includeusingnamespace std;struct point{ double x,y; }; s原创 2010-07-30 21:05:00 · 386 阅读 · 0 评论 -
tzc3056 点关于直线的对称点
题目链接: tzc3056方法:计算几何 注意:本题在输出结果的时候要将数据强制转换成整型,不能用%.0lf输出,否则会WA。代码:#include #include using namespace std;const double eps=1e-1原创 2011-08-04 19:05:28 · 734 阅读 · 0 评论 -
tzc1200 求两直线的夹角
题目链接: tzc1200方法:计算几何 代码:#include #include using namespace std;struct point {double x,y;};struct line { point s,e; };const doub原创 2011-08-04 19:00:20 · 831 阅读 · 0 评论 -
pku2318toys
题目:pku2318代码:计算几何+二分(AC)// 本代码参照 low coder//计算几何(叉积) + 二分搜索 // n m x1 y1 x2 y2. // (0 #include #includeusingnamespace std;#define infinity 1e20 #define EP 1e-10 constdouble PI = 2.0*asin(1.0); //高精度求PI struct point {double x,y;}; //点 struct line原创 2010-08-05 22:13:00 · 455 阅读 · 0 评论 -
pku2318TOYS
题目:pku2318题意:一个句型的大盒子,加上一定数量的隔板,划分为n个小盒子。给某点坐标,判断该点是在哪个小盒子的范围内。思路:叉积判断点是在隔板的哪一侧,二分搜索逐渐缩小范围。代码:#include using namespace std;int count[5005];struct Node{ __int64 x,y;};struct Edge{ Node up; Node low;}boundary[5005];inline __int64 Cros转载 2010-08-05 21:41:00 · 355 阅读 · 0 评论 -
pku1380Equipment Box
题目:pku1380代码://(1 #include #include using namespace std;int main(int argc, char *argv[]){ int t,a,b,x,y; double A,B,angle,len; cin>>t; while(t--) { cin>>a>>b>>x>>y; if(ab) { printf("Box cannot be dropped./n");continue; }原创 2010-08-05 12:14:00 · 423 阅读 · 0 评论 -
pku1410Intersection
题目链接:pku1410代码://where (xstart, ystart) is the start and (xend, yend) the end point of the line and (xleft, ytop)//the top left and (xright, ybottom) the bottom right corner of the rectangle#include #include using namespace std;struct point原创 2010-07-30 11:45:00 · 352 阅读 · 0 评论 -
pku1113wall
<br />题目:pku1113wall<br /> <br />方法:凸包问题<br /> <br />代码:<br /> <br />//3 <= N <= 1000) 1 <= L <= 1000) (-10000 <= Xi, Yi <= 10000) #include <iostream>#include <algorithm>#include <cmath>using namespace std;const double pi=acos(-1.0);struct p原创 2010-08-01 11:34:00 · 490 阅读 · 0 评论 -
pku1228Grandpa's Estate
<br />题目:pku1228 <br /> <br />代码:<br /> <br />//方法:凸包问题//本题大意是已知部分的点,判断这些点所确定的凸包是否唯一//当已知的点数少于6个时,所确定的凸包肯定不唯一//当任意一条边上(包括端点)少于3个点,所确定的凸包不唯一//1 <= n <= 1000#include <iostream>#include <algorithm>#include <cmath>using namespace std;/*==原创 2010-08-01 16:30:00 · 532 阅读 · 0 评论 -
pku1624 This Takes the Cake
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1624代码:#include #include using namespace std;const double INF=0xffffffff;const double eps=1e-10;struct point{ double x,y; };typedef point polygon[8]; //计算多边形面积double polygon_area(p原创 2010-08-03 18:21:00 · 426 阅读 · 0 评论 -
pku3304Segments
题目链接:pku3304题意:已知一些线段的始末坐标,看是否存在一条直线,能够与所有已知的线段相交。思路:枚举所有端点构成的直线,看其是否与已知的所有线段相交。只要找的一条,即可跳出循环。代码:// n ≤ 100 two floating point numbers a and b are equal if |a - b| #include using namespace std;const double eps=1e-8;struct point { double x,y原创 2010-08-03 21:24:00 · 358 阅读 · 0 评论 -
pku2242The Circumference of the Circle
<br />题目链接:pku2242<br /> <br />题意:已知三角形的顶点坐标,求三角形的外接圆的周长。<br /> <br />方法:已知三角形三边a,b,c,可以用海伦公式求其面积。S=sqrt(p*(p-a)*(p-b)*(p-c)),其中p=(a+b+c)/2.<br /> <br />知道a,b,c及外接圆半径R,则三角形的面积为 S=a*b*c/(4*R)。本题由此公式即可算出外接圆半径。<br /> <br />代码一:<br /> <br />#include <iostream>原创 2010-08-04 13:13:00 · 449 阅读 · 0 评论 -
pku1648Countryside Highway
题目:pku1648代码://1 using namespace std;const double eps=1e-10;struct point { double x, y; };double max(double x,double y){ return x>y?x:y; }double min(double x,double y){ return x原创 2010-08-02 16:07:00 · 559 阅读 · 0 评论 -
pku1118Lining Up
<br />题目链接:pku1118Lining Up<br /> <br />代码:<br /> <br />// 1 < N < 700 #include <iostream>#include <cmath>#include <algorithm>using namespace std;const double eps=1e-10;const double INF=0xffffffff;struct point { long x,y; };bool原创 2010-08-02 20:45:00 · 395 阅读 · 0 评论 -
pku3512Incidental Points
<br />题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3512<br /> <br />题目大意: 输入一些点,求最多有几点共线。<br /> <br />注意:本题的输入是比较的繁琐的,需要好好的控制。特别注意的是x,y可能是负数。<br /> <br />因此,当输入一个减号时,不一定是这个测试样例结束。这样容易造成WA.<br /> <br />思路:每次把一个顶点作为起点,计算其余点与该点所形成的直线的斜率。<br /> <br />然后进行原创 2010-08-02 21:18:00 · 379 阅读 · 0 评论 -
pku1899Farmer Bill's Problem
题目:pku1899代码:该代码参考何长兵的博客//1 using namespace std;struct point{ int x,y; };struct circle{ int x,y,r; };struct rectangle{ point ld,rp; };circle c[105];rectangle r[105];int n,used[105];// 判断两个矩形是否相交bool rectangle_cross(rectangl原创 2010-08-04 20:21:00 · 482 阅读 · 0 评论 -
tzc3109 两圆外公切线之交
题目链接:tzc3109方法:计算几何思想:当两个圆的半径相同或者两圆关系为内含时不存在外公切线交点。当存在外公切线交点时,由于知道两半径,而外公切线与两圆心够成的直线及圆心与切点的连线所够成的图形中,得到交点到两圆圆心的向量之比 等于半径之比,从而(x-o1原创 2011-08-05 14:55:21 · 999 阅读 · 0 评论