Pagini recente » Cod sursa (job #739319) | Cod sursa (job #3190199) | Cod sursa (job #257954) | Cod sursa (job #2535748) | Cod sursa (job #2455715)
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
using namespace std;
typedef long long lint;
int gcd(int a, int b)
{
if(b == 0){
return a;
}
return gcd(b, a%b);
}
struct boi{
int a, b;
void yeet()
{
cout << a << " " << b << "\n";
}
void susta()
{
int x = gcd(a, b);
a /= x; b /= x;
}
void neg()
{
a = -a; b = -b;
}
};
bool operator<(const boi & lhs, const boi & rhs)
{
return lhs.a < rhs.a || (lhs.a == rhs.a && lhs.b < rhs.b);
}
int trap(int a)
{
return a*(a-1)/2;
}
ifstream fin("trapez.in");
ofstream fout("trapez.out");
vector<boi> points;
map<boi, int> parale;
int main()
{
int n;
fin >> n;
for(int i = 0; i < n; i++){
int a, b;
fin >> a >> b;
points.push_back({a, b});
}
for(int i = 0; i < n; i++){
boi p1 = points[i];
for(int j = i+1; j < n; j++){
boi p2 = points[j];
boi ln = {p1.a - p2.a, p1.b - p2.b};
ln.susta();
if(parale.find(ln) == parale.end()){
ln.neg();
if(parale.find(ln) == parale.end()){
parale[ln] = 0;
}
}
parale[ln]++;
}
}
lint sol = 0;
for(auto ln : parale){
sol += trap(ln.second);
}
fout << sol;
return 0;
}