POJ 3335 Rotating Scoreboard注意:题目给出的点集默认是顺时针的。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ double x, y;}p[105], tmp[105], q[105];double a, b, c;void get_line(point p1, point p2){ a = p2.y - p1.y; b = p1.x - Read More
posted @ 2012-09-03 22:11 To be an ACMan Views(415) Comments(0) Diggs(0)
Pick公式:平面上以格子点为顶点的简单多边形,如果边上的点数为on,内部的点数为in,则它的面积为area=on/2+in-1利用gcd求每个边上的点数。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>using namespace std;struct point{ int x, y;}p[5];int gcd(int a, int b){ return b == 0 ? a : gc Read More
posted @ 2012-09-03 17:50 To be an ACMan Views(153) Comments(0) Diggs(0)
注意这题 多边形有凹有凸。水题。不解释View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>#define lld __int64using namespace std;struct point{ lld x, y;}p[1000003];lld cal(int n, point *p){ int i; lld s = 0; p[n] = p[0]; for(i = 0; i < n; i Read More
posted @ 2012-09-03 17:00 To be an ACMan Views(197) Comments(0) Diggs(0)
一定要注意 总的点数 n<= 2 时 graham不适用。还要注意 graham找到凸包后 注意 top <=2 时面积为0。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ double x, y;}p[10003];double det(double x1, double y1, double x2, double y2){ return x1 * y2 Read More
posted @ 2012-09-03 15:49 To be an ACMan Views(318) Comments(0) Diggs(0)