Pagini recente » Cod sursa (job #1677707) | Cod sursa (job #1436556) | Cod sursa (job #325172) | Cod sursa (job #1854084) | Cod sursa (job #2294693)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("trapez.in") ;
ofstream g("trapez.out") ;
int n ;
double a[300000] ;
struct coordonate
{
double x , y ;
}c[30000];
int main()
{
f >> n ;
for( int i = 1 ; i <= n ; i ++ )
f >> c[i].x >> c[i].y ;
int l = 0 ;
double nr = 0 ;
for( int i = 1 ; i <= n - 1 ; i ++ )
for( int j = i + 1 ; j <= n ; j ++ ){
a[++l] = ( c[i].x - c[j].x ) / ( c[i].y - c[j].y ) ;
//g << a[l] << " " ;
}
sort( a , a + l + 1 ) ;
a[l + 1] = 0 ;
for( int i = 2 ; i <= l ; i ++ ){
int nrp = 1 ;
while( a[i] == a[i - 1] ) {
nrp ++ ;
i ++ ;
}
nr += nrp * ( nrp - 1 ) / 2 ;
}
g << nr ;
}