#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
struct point {
long long x, y;
int f;//代表在哪一个象限
friend point operator - (point a, point b) {
return (point){a.x-b.x, a.y-b.y};
}
};
//利用叉积的正负来作cmp.(即是按逆时针排序).
long long cross(point a, point b, point c) {//AB X AC
return (b.x-a.x) * (c.y-a.y) - (b.y-a.y) * (c.x-a.x);
}
bool cmp(const point &a, const point &b) {//逆时针排序
point origin;
origin.x = origin.y = 0;
return cross(origin, a, b) < 0;
}
//利用complex的内建函数
#include<complex>
#define x real()
#define y imag()
#include<algorithm>
using namespace std;
bool cmp(const Point& p1, const Point& p2) {
return arg(p1) < arg(p2);
}
//利用象限加上极角,叉积
bool cmp(const point &a, const point &b) {
//先按象限排序,再按极角排序,再按远近排序
if (a.y == 0 && b.y == 0 && a.x*b.x <= 0)return a.x>b.x;
if (a.y == 0 && a.x >= 0 && b.y != 0)return true;
if (b.y == 0 && b.x >= 0 && a.y != 0)return false;
if (b.y*a.y <= 0)return a.y>b.y;
point one;
one.y = one.x = 0;
return cross(one,a,one,b) > 0 || (cross(one,a,one,b) == 0 && a.x < b.x);
}
//或者
int cal(point a) {//计算象限
if(a.x > 0 && a.y >= 0) return 1;
if(a.x <= 0 && a.y > 0) return 2;
if(a.x < 0 && a.y <= 0) return 3;
if(a.x >= 0 && a.y < 0) return 4;
}
bool cmp(const point a, const point b) {
//先按象限排序,再按极角排序
if(a.f < b.f) return true;
if(a.f > b.f) return false;
long long tmp = cross(s, a, b);
if(tmp > 0) return true;
return false;
}
//求cosA的符号
bool ok(point a, point b, point c) {
long long tmp = (b.x-a.x) * (c.x-a.x) + (b.y-a.y) * (c.y - a.y);
if(tmp > 0) return true;
return false;
}
#include #include #include #include #include using namespace std;struct point { long long x, y; int f;//代表在哪一个象限 friend point operator - (point a, point b) { return (point){a