Pagini recente » Cod sursa (job #273690) | Cod sursa (job #1959513) | Cod sursa (job #1381728) | Cod sursa (job #3135040) | Cod sursa (job #2764246)
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int const N = 1e6 + 3;
typedef long long ll;
struct Point{
ll x , y;
Point (){
x = y = 0LL;
}
Point (ll X , ll Y){
x = X , y = Y;
}
};
struct Line{
Point a , b;
ll v1 , v2;
Line (){
}
Line (Point A , Point B){
a = A , b = B;
v1 = A.y - B.y;
v2 = A.x - B.x;
}
bool operator == (Line r) const{
return v1 * r.v2 == v2 * r.v1;
}
bool operator < (Line r) const{
return v1 * r.v2 < v2 * r.v1;
}
};
Point V [1001];
Line v [N];
int main()
{
freopen ("trapez.in" , "r" , stdin);
freopen ("trapez.out" , "w" , stdout);
int n;
scanf ("%d" , &n);
for(int i = 1 ; i <= n ; ++ i){
ll a , b;
scanf ("%lld%lld" , &a , &b);
Point P (a , b);
V [i] = P;
}
int k = 0;
for(int i = 1 ; i < n ; ++ i)
for(int j = i + 1 ; j <= n ; ++ j){
Line x (V [i] , V [j]);
v [++ k] = x;
}
sort (v + 1 , v + 1 + k);
ll ans = 0LL;
Line Last;
int lg;
for(int i = 1 ; i <= n ; ++ i){
if (i == 1){
Last = v [1];
lg = 1;
continue;
}
if (v [i] == Last)
++ lg;
else{
ans = ans + 1LL * lg * (lg - 1) / 2LL;
Last = v [i];
lg = 1;
}
}
ans = ans + 1LL * lg * (lg - 1) / 2LL;
printf ("%lld" , ans);
return 0;
}