Pagini recente » Cod sursa (job #420008) | Cod sursa (job #1665963) | Cod sursa (job #1651282) | Cod sursa (job #1569992) | Cod sursa (job #687664)
Cod sursa(job #687664)
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double keps = 0.0001;
const int kmaxn = 1005;
int n, sol, px[kmaxn], py[kmaxn];
double angles[kmaxn * kmaxn];
void read(){
assert(freopen("trapez.in","r",stdin)!=NULL);
scanf("%d",&n);
int i;
for(i = 1; i <= n; ++i)
scanf("%d%d",&px[i] ,&py[i]);
}
int modul(int x){
if(x > 0)
return x;
return -x;
}
void solve(){
int i, j, u = 0, curent = 0;
for(i = 1; i <= n; ++i)
for(j = i + 1; j <= n; ++j)
angles[++u] = (double)((double)modul(px[i] - px[j])) / ((double)modul(py[i] - py[j]));
sort(angles + 1, angles + u + 1);
for(i = 1; i <= u; ++i)
if(angles[i] - angles[i - 1] < keps){
++curent;
sol += curent;
}
else
curent = 0;
sol /= 2;
}
void write(){
assert(freopen("trapez.out","w",stdout)!=NULL);
printf("%d",sol);
}
int main(){
read();
solve();
write();
return 0;
}