hzwer已经说的很好了,在此只能跪烂了
1 /************************************************************** 2 Problem: 1914 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:88 ms 7 Memory:3160 kb 8 ****************************************************************/ 9 10 #include <cstdio> 11 #include <cmath> 12 #include <algorithm> 13 14 using namespace std; 15 typedef long long ll; 16 typedef double lf; 17 const int N = 100005; 18 19 int n; 20 ll cnt = 0; 21 22 struct P { 23 ll x, y; 24 lf an; 25 P() {} 26 P(ll _x, ll _y, lf _an) : x(_x), y(_y), an(_an) {} 27 }a[N]; 28 inline bool operator < (const P &a, const P &b) { 29 return a.an < b.an; 30 } 31 inline ll operator * (const P &a, const P &b) { 32 return (ll) a.x * b.y - a.y * b.x; 33 } 34 35 inline int read() { 36 int x = 0, sgn = 1; 37 char ch = getchar(); 38 while (ch < '0' || '9' < ch) { 39 if (ch == '-') sgn = -1; 40 ch = getchar(); 41 } 42 while ('0' <= ch && ch <= '9') { 43 x = x * 10 + ch - '0'; 44 ch = getchar(); 45 } 46 return sgn * x; 47 } 48 49 void work() { 50 int r = 1, t = 0, i; 51 for (i = 1; i <= n; ++i) { 52 while ((r % n + 1) != i && a[i] * a[r % n + 1] >= 0) ++t, ++r; 53 cnt += (ll) t * (t - 1) / 2; 54 --t; 55 } 56 } 57 58 int main() { 59 n = read(); 60 int i, X, Y; 61 for (i = 1; i <= n; ++i) { 62 X = read(), Y = read(); 63 a[i] = P(X, Y, atan2(Y, X)); 64 } 65 sort(a + 1, a + n + 1); 66 work(); 67 printf("%lld\n", (ll) n * (n - 1) * (n - 2) / 6 - cnt); 68 return 0; 69 }