Pagini recente » Cod sursa (job #2166003) | Cod sursa (job #3136956) | Cod sursa (job #1637371) | Cod sursa (job #592439) | Cod sursa (job #1330069)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
const int MAX = 1010;
const double eli = 0.001;
const int INF = 0x3f3f3f3f;
struct Punct{
int x, y;
};
Punct p[MAX];
int N;
int nrp, pe;
int nrt;
double pa[MAX * MAX];
double Panta( Punct A, Punct B );
int main()
{
int i, j;
fin >> N;
for ( i = 1; i <= N; i++ )
fin >> p[i].x >> p[i].y;
for ( i = 1; i < N; i++ )
for ( j = i + 1; j <= N; j++ )
{
pa[++nrp] = Panta( p[i], p[j] );
}
/* for ( i = 1; i <= nrp; i++ )
fout << pa[i] << ' ';
fout << '\n'; */
sort( pa + 1, pa + 1 + nrp );
/* for ( i = 1; i <= nrp; i++ )
fout << pa[i] << ' ';
fout << '\n'; */
pe = 0;
for ( i = 1; i < nrp; i++ )
{
pe = 0;
while ( pa[i] == pa[i + 1] )
i++, pe++;
nrt += ( pe * ( pe + 1 ) / 2 );
}
fout << nrt << '\n';
fin.close();
fout.close();
return 0;
}
double Panta( Punct A, Punct B )
{
if ( B.x == A.x ) return INF;
return (double)( B.y - A.y ) / ( B.x - A.x );
}