Pagini recente » Cod sursa (job #1141738) | Cod sursa (job #2481829)
#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;
map < long double, int > unghi1;
map < long double, int > :: iterator it ;
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=i+1;j<=n;j++)
{ /*if(v[i].first == v[j].first) unghi.push_back((2e9 + 2));
else unghi.push_back((v[i].second-v[j].second)/(long double)(v[i].first-v[j].first));*/
if( v[i].first==v[j].first ) unghi1[2e9 + 2]++;
else unghi1 [ (v[i].second-v[j].second)/(long double)(v[i].first-v[j].first) ] ++;
}
int ans=0;
for( it=unghi1.begin() ; it!=unghi1.end();it++)
{ int val=it->second;
ans+=(val*(val-1))/2;
}
g<<ans;
return 0;
}