0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:56:28 +00:00

#630. 0818三角形(triangle)

https://sjzezoj.com/submission/18972
This commit is contained in:
Baoshuo Ren 2021-08-19 08:34:27 +08:00 committed by Baoshuo Ren
parent 0ae24246f8
commit c3f9ea426f
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

34
S2OJ/630/630.cpp Normal file
View File

@ -0,0 +1,34 @@
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
long long n, ans, x[3005], y[3005], t, l;
double b[10000005];
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
ans = n * (n - 1) * (n - 2) / 6;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
t = 0;
l = 1;
for (int j = i - 1; j > 0; j--) {
b[++t] = x[i] - x[j] ? (double)(y[i] - y[j]) / (double)(x[i] - x[j]) : 0x3f3f3f3f3f3f3f3f;
}
sort(b + 1, b + 1 + t);
for (int j = 2; j <= t; j++) {
if (b[j] == b[j - 1]) {
l++;
} else {
ans -= l * (l - 1) / 2;
l = 1;
}
}
ans -= l * (l - 1) / 2;
}
cout << ans << endl;
return 0;
}