Pagini recente » Cod sursa (job #294870) | Cod sursa (job #3126158) | Cod sursa (job #311302) | Cod sursa (job #2130367) | Cod sursa (job #2734949)
#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 ;
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 ++)
{
int a = v[f].first - v[e].first, b = v[f].second - v[e].second ;
int aux = __gcd(a, b) ;
//aux = max(aux, 1) ;
a /= aux ;
b /= aux ;
Map[a * 10000000000 + b] ++ ;
}
long long tot = 0 ;
for(auto f = Map.begin() ; f != Map.end() ; f ++)
tot += (*f).second * ((*f).second - 1) / 2 ;
cout << tot ;
return 0 ;
}