Pagini recente » Cod sursa (job #2588003) | Cod sursa (job #909792) | Cod sursa (job #1737422) | Cod sursa (job #254208) | Cod sursa (job #940496)
Cod sursa(job #940496)
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define maxn 1001
#define maxp 1000001
#define inf ( 1 << 30 )
struct punct
{
int x, y ;
};
int n ;
punct v[maxn] ;
int nrp ;
double panta[maxp] ;
double ppanta( punct A, punct B )
{
if( A.x == B.x )
return inf ;
return ( ( double ) B.y - A.y ) / ( B.x - A.x ) ;
}
void citire()
{
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
cin >> n ;
for(int i = 1; i <= n; ++i )
cin >> v[i].x >> v[i].y ;
}
void calc_pante()
{
for(int i = 1; i <= n; ++i )
for(int j = i + 1 ; j <= n; ++j )
panta[ ++nrp ] = ppanta( v[i], v[j] ) ;
sort( panta + 1, panta + nrp + 1 ) ;
}
void afisare()
{
int act = 0 ;
int sol = 0 ;
for(int i = 1; i < nrp; ++i )
{
if( panta[i] == panta[ i + 1 ] )
++act ;
else
{
sol += ( act * ( act - 1 ) / 2 ) ;
act = 1 ;
}
}
cout << sol ;
}
int main()
{
citire() ;
calc_pante() ;
afisare() ;
return 0 ;
}