Pagini recente » Cod sursa (job #2778099) | Cod sursa (job #841953) | Cod sursa (job #2413704) | Cod sursa (job #487099) | Cod sursa (job #2481804)
#include <bits/stdc++.h>
using namespace std;
ifstream f ( "trapez.in" ); ofstream g ( "trapez.out" );
pair < long double ,long double > v[1005];
vector <long double> unghi;
int main()
{ int n;
f>>n;
for(int i=1;i<=n;i++) f>>v[i].first>>v[i].second;
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)
{ if(v[i].first == v[j].first) unghi.push_back((1<<30));
else unghi.push_back( abs(v[i].second-v[j].second) / (long double)(abs(v[i].first-v[j].first)));
}
sort(unghi.begin(),unghi.end());
long long ans=0,cnt=0;
for(int i=1;i<unghi.size();i++)
{ if(unghi[i-1]==unghi[i]) cnt ++;
else
{ ans+=cnt*(cnt-1)/2;
cnt=1;
}
}
g<<ans+(cnt*(cnt-1))/2;
return 0;
}