Mai intai trebuie sa te autentifici.
Cod sursa(job #76102)
Utilizator | Data | 7 august 2007 22:53:51 | |
---|---|---|---|
Problema | Trapez | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.07 kb |
#include <cstdio>
#include <algorithm>
#include <cmath>
const int maxn = 1000;
const double eps = 0.0000000000000001;
const double inf = 2000000002.0;
FILE *in = fopen("trapez.in","r"), *out = fopen("trapez.out","w");
struct punct
{
int x, y;
};
int n;
punct a[maxn];
int k;
struct dbl
{
double p;
};
double p[maxn*maxn];
void read()
{
fscanf(in, "%d", &n);
for ( int i = 0; i < n; ++i )
fscanf(in, "%d %d", &a[i].x, &a[i].y);
}
void go()
{
for ( int i = 0; i < n; ++i )
for ( int j = i + 1; j < n; ++j )
{
if ( a[i].x == a[j].x )
p[k++] = inf;
else
p[k++] = (double)( a[i].y - a[j].y ) / ( a[i].x - a[j].x );
}
}
//bool operator<(const dbl &x, const dbl &y)
//{
// return x.p - y.p < eps;
//}
int main()
{
read();
go();
std::sort(p, p+k);
int cnt = 0;
for ( int i = 1; i < k; ++i )
if ( p[i] - p[i-1] < eps )
++cnt;
fprintf(out, "%d\n", cnt);
return 0;
}