-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.cpp
39 lines (39 loc) · 937 Bytes
/
basic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
struct point
{
ll x, y;
point() {}
point(ll x, ll y) : x(x), y(y) {}
point& operator-=(const point& p)
{
x -= p.x;
y -= p.y;
return *this;
}
point& operator+=(const point& p)
{
x += p.x;
y += p.y;
return *this;
}
point& operator*=(ll r)
{
x *= r;
y *= r;
return *this;
}
point& operator/=(ll r)
{
x /= r;
y /= r;
return *this;
}
point operator+(const point& p) { return point(*this) += p; }
point operator-(const point& p) { return point(*this) -= p; }
point operator*(ll r) { return point(*this) *= r; }
point operator/(ll r) { return point(*this) /= r; }
// cros product
ll operator^(const point& p) { return x * p.y - y * p.x; }
// dot product
ll operator*(const point& p) { return x * p.x + y * p.y; }
ll norm() { return *this * *this; }
};