Cod sursa(job #2294599)

Utilizator Dragomiralexandru621@yahoo.comDragomir ionut alexandru [email protected] Data 2 decembrie 2018 16:35:02
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>

using namespace std;
ifstream f("trapez.in") ;
ofstream g("trapez.out") ;
int n , x[300000] , y[300000] , a[300000] , b[300000] ;
int main()
{
 f >> n ;
 for( int i = 1 ; i <= n ; i ++ )
    f >> x[i] >> y[i] ;
int l = 0 ;

 for( int i = 1 ; i <= n - 1 ; i ++ )
    for( int j = i + 1 ; j < n ; j ++ ){
      a[++l] = y[i] - y[j] ;
      b[l] = x[i] - x[j] ;
    }
 int nr = 0 ;
 for( int i = 1 ; i < l ; i ++ )
    for( int j = i + 1  ; j <= l ; j ++ )
      if( a[i] * b[i] == a[j] * b[j] )
       nr ++ ;
g << nr ;
}