Pagini recente » Cod sursa (job #246838) | Cod sursa (job #1137680) | Cod sursa (job #1533508) | Cod sursa (job #2791874) | Cod sursa (job #2734963)
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#define MOD 1000000007
using namespace std;
ifstream cin ("trapez.in") ;
ofstream cout("trapez.out") ;
unordered_map<unsigned long long, int > Map ;
int n ;
vector<pair<int, int> > v ;
vector<unsigned long long> vv ;
int main()
{
cin >> n ;
for(int f = 1 ; f <= n ; f ++)
{
int a, b ;
cin >> a >> b ;
v.push_back({a, b}) ;
}
for(int f = 0 ; f < v.size() ; f ++)
for(int e = f + 1 ; e < v.size() ; e ++)
{
long long a = v[f].first - v[e].first, b = v[f].second - v[e].second ;
long long aux = __gcd(a, b) ;
//aux = max(aux, 1) ;
a /= aux ;
b /= aux ;
vv.push_back(a * 100000000000 + b) ;
}
sort(vv.begin(), vv.end()) ;
long long tot = 0 ;
int curent = 1 ;
for(int f = 1 ; f < vv.size() ; f ++)
{
if(vv[f] == vv[f - 1])curent ++ ;
else
{
tot += curent * (curent - 1) / 2 ;
curent = 1 ;
}
}
cout << tot ;
return 0 ;
}