nyist_68_三点顺序
摘要:1 #include <cstdio> 2 #include <iostream> 3 4 using namespace std; 5 6 struct point { 7 int x, y; 8 }A, B, C; 9 10 int crossProd(point A, point B, point C) {//叉乘 11 return (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x);12 }13 14 int main() {15 while (1) {16 scanf ("%d%d...
阅读全文
posted @
2012-06-15 21:56
Try86
阅读(280)
推荐(0)
nyist_78_圈水池
摘要:1 #include <cmath> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <iostream> 5 6 using namespace std; 7 8 const int N = 105; 9 10 struct point {11 long long x, y;12 }p[N];13 14 long long dis(point A, point B) {//两点距离 15 return (long long)sqrt((A.x - B.x) * (A.x - B.x) +
阅读全文
posted @
2012-06-15 21:55
Try86
阅读(162)
推荐(0)
pku 2526(Center of symmetry)
摘要:1 /* 2 * 判断一堆点组成的形状是否为对称的 3 */ 4 5 #include <cmath> 6 #include <cstdio> 7 #include <cstdlib> 8 #include <iostream> 9 10 using namespace std;11 12 const int N = 10005;13 const double EPS = 1e-8;14 15 struct point {16 double x, y;17 }p[N], s;18 int used[N];19 20 int Rlcmp(doubl
阅读全文
posted @
2012-06-03 08:59
Try86
阅读(218)
推荐(0)
pku 2187(最远点对,旋转卡壳)
摘要:1 #include <cstdio> 2 #include <cstdlib> 3 #include <iostream> 4 5 using namespace std; 6 7 const int N = 50005; 8 9 //旋转卡壳(变化)求凸包直径O(n)10 struct point {11 int x, y;12 }p[N];13 14 int dis(point A, point B) {15 return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);16 }17 18 i
阅读全文
posted @
2012-05-31 07:41
Try86
阅读(219)
推荐(0)
RQNOJ 358线段
摘要:#include <cmath>#include <cstdio>#include <iostream>using namespace std;double dis(double x1, double y1, double x2, double y2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}int main() { double x1, y1, r1, x2, y2, r2; while (scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1,
阅读全文
posted @
2012-05-13 08:23
Try86
阅读(160)
推荐(0)
RQNOJ 411area(求简单多边形面积)
摘要:/** 求简单多边形面积 */ #include <cstdio>#include <iostream>using namespace std;const int N = 105;struct point { int x; int y;}p[N];int crossProd(point A, point B) { return A.x*B.y - A.y*B.x;}int compArea(int n) { p[n] = p[0]; int area = 0; for (int i=0; i<n; ++i) area += crossProd(p[i], p[i+
阅读全文
posted @
2012-05-13 07:36
Try86
阅读(166)
推荐(0)
RQNOJ 150轰炸(求最多有几个点共线)
摘要:/** 题意:求最多有多少个点共线 * 思路:枚举两点求直线,枚举有多少个点在直线上 */#include <cstdio>#include <iostream>using namespace std;const int N = 705;struct point { int x; int y;}p[N];int solve(int n) { int a, b, c, counts, ans = -1; for (int i=0; i<n; ++i) { for (int j=i+1; j<n; ++j) { a = p[j].y - p[i].y; //一般
阅读全文
posted @
2012-05-13 07:26
Try86
阅读(279)
推荐(0)
pku 2187(最远点对)
摘要:1 /* 2 * 题目要求:求一组点中距离最远的一对的距离 3 * 解法:凸包+枚举 4 */ 5 6 #include <cmath> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <iostream>10 11 using namespace std;12 13 const int N = 50005;14 15 struct point {16 int x;17 int y;18 }p[N], stack[N];19 20 int dis(point A, point B) {21
阅读全文
posted @
2012-04-27 07:26
Try86
阅读(244)
推荐(0)
pku 3714(最近点对)
摘要:1 /* 2 * 题目要求:求最近点对(一个点在station内,一个点在agent内) 3 */ 4 5 #include <cmath> 6 #include <cstdio> 7 #include <cstdlib> 8 #include <iostream> 9 #include <algorithm>10 11 using namespace std;12 13 const int N = 200005;14 const double INF = 1e20;15 16 struct point {17 int f;18 do
阅读全文
posted @
2012-04-26 21:43
Try86
阅读(221)
推荐(0)
hdu 1007(最近点对)
摘要:1 /* 2 * 题目要求:求最近点对 3 */ 4 5 #include <cmath> 6 #include <cstdio> 7 #include <cstdlib> 8 #include <iostream> 9 #include <algorithm>10 11 using namespace std;12 13 const int N = 100005;14 const double INF = 1e15;15 16 struct point {17 double x;18 double y;19 }p[N];20 int
阅读全文
posted @
2012-04-26 20:23
Try86
阅读(251)
推荐(0)
FZU 1382(求三角形的外接圆与内切圆)
摘要:1 /* 2 * 题目要求:求三角形内接圆面积与外接圆面积之比 3 * 内切圆半径:r=2*s/(a+b+c) ; 4 * 外接圆半径为 R=(a*b*c)/(s*4); 5 * 对于一般的三角形,内切圆半径公式如下: 6 * r=sqrt[(p-a)(p-b)(p-c)/p] 7 * 在直角三角形的内切圆中,有这样两个简便公式: 8 * 1、两直角边相加的和减去斜边后除以2,得数是内切圆的半径。 9 * 2、两直角边乘积除以直角三角形周长,得数是内切圆的半径。 10 * 1、r=(a+b-c)/2(注:s是Rt△的面积,a, b是Rt△的2个直角边,c是斜...
阅读全文
posted @
2012-04-25 22:10
Try86
阅读(428)
推荐(0)
pku 1410(判断线段是否跟矩形相交)
摘要:1 /* 2 * 题目要求:判断线段是否跟矩形相交 3 * 注意:线段完全在矩形内也是相交 4 * 解法:分别判断线段是否跟矩形的四条边相交,再判断线段的两个端点是否都在矩形内 5 */ 6 7 #include <cstdio> 8 #include <cstdlib> 9 #include <iostream>10 11 using namespace std;12 13 struct point {14 double x;15 double y;16 }A, B, C, D, E, F;17 18 double crossProd(point A, p
阅读全文
posted @
2012-04-25 13:11
Try86
阅读(426)
推荐(0)
hdu 1348(凸包)
摘要:1 /* 2 * 凸包 3 * 注意:给出的点为整点数,不要设某一精度值! 4 */ 5 6 #include <cmath> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <iostream>10 11 using namespace std;12 13 const int N = 1005;14 const double PI = 3.1415927;15 16 struct point {17 double x;18 double y;19 }p[N], stack[N];20 21
阅读全文
posted @
2012-04-24 22:34
Try86
阅读(937)
推荐(0)
hdu 1785(对向量排序)
摘要:1 /* 2 * 题目要求:对一组向量按与x轴的正向夹角从小到大排序 3 * 解法:借用求凸包的排序规则即可 4 */ 5 6 #include <cmath> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <iostream>10 11 using namespace std;12 13 const int N = 105;14 const double eps = 1e-8;15 16 struct point {17 double x;18 double y;19 }p[N];20
阅读全文
posted @
2012-04-24 22:07
Try86
阅读(286)
推荐(0)
hdu 2150(判断折线是否相交)
摘要:1 /* 2 * 题目要求:判断给出的一些折线段是否相交 3 * 解法:枚举每条折线段上的每段线段,判断其是否与其它折线段的线段相交 4 */ 5 6 #include <cstdio> 7 #include <cstdlib> 8 #include <iostream> 9 10 using namespace std;11 12 const int N = 35;13 const int M = 105;14 15 int num[N];16 struct point {17 double x;18 double y;19 }p[N][M];20 21
阅读全文
posted @
2012-04-24 21:34
Try86
阅读(431)
推荐(0)
hdu 2202(凸包+枚举凸包上的点)
摘要:1 /* 2 * 题目要求:求三角形的最大面积 3 * 方法:凸包+枚举凸包上的点 4 */ 5 6 #include <cmath> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <iostream>10 11 using namespace std;12 13 const int N = 50005;14 const double eps = 1e-8;15 16 struct point {17 int x;18 int y;19 }p[N], stack[N];20 21 bool
阅读全文
posted @
2012-04-24 18:53
Try86
阅读(666)
推荐(0)
pku 2954(pick定理的应用)
摘要:/* * pick定理的应用* pick定律: area = inside + onedge / 2 - 1; */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct point { int x; int y;}A, B, C;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x)
阅读全文
posted @
2012-04-23 22:05
Try86
阅读(248)
推荐(0)
pku 1687(求面积最大的多边形的编号)
摘要:/** 题目要求:求面积最大的那个面的编号* 方法:分别求每个面的面积,并比较最大的面积 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 55;struct point { int x; int y;}p[N], sp[N];double crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A
阅读全文
posted @
2012-04-23 21:46
Try86
阅读(222)
推荐(0)
hdu 2215(凸包+最小圆覆盖)
摘要:/* 凸包+最小圆覆盖 枚举任意3点找其最小覆盖圆(当为钝角三角形时不是外接圆,而是以其最长边为直径的圆)。 当为外接圆时,半径公式为r=abc/4s;(推导为如下: 由正弦定理,a/sinA=b/sinB=c/sinC=2R,得sinA=a/(2R), 又三角形面积公式S=(bcsinA)/2,所以S=(abc)/(4R),故R=(abc)/(4S).*/#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const
阅读全文
posted @
2012-04-23 21:01
Try86
阅读(1248)
推荐(0)
hdu 1392(求凸包周长)
摘要:/** 题目要求:求凸包的周长 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 105;const double eps = 1e-8;struct point { int x; int y;}p[N], stack[N];bool isZero(double x) { return (x > 0 ? x : -x) < eps;}double dis(point A, p
阅读全文
posted @
2012-04-23 18:46
Try86
阅读(886)
推荐(0)