Cod sursa(job #2308977)
| Utilizator | Data | 28 decembrie 2018 10:19:29 | |
|---|---|---|---|
| Problema | Trapez | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
int main()
{
int N; f>>N;
vector<pair<int,int>> V(N);
for(auto &p:V) f>>p.first>>p.second;
map<pair<int,int>,int> A;
for(int i=0;i<V.size();i++)
for(int j=i+1;j<V.size();j++)
{
int a=V[i].second-V[j].second,
b=V[j].first-V[i].first,
d=__gcd(a,b);
A[{a/d,b/d}]++;
}
uint64_t result=0;
for(auto a:A)
{
uint64_t nr=a.second;
result+=1LL*nr*(nr-1)/2;
}
g<<result;
return 0;
}
