Pagini recente » Cod sursa (job #1303643) | Cod sursa (job #1290236) | Cod sursa (job #609253) | Cod sursa (job #1122939) | Cod sursa (job #1839750)
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <climits>
using namespace std;
int N;
struct point{
int x;
int y;
};
point P[1000];
double pante[1000000];
void citire(){
cin >> N;
for(int i=0; i<N; i++)
cin >> P[i].x >> P[i].y;
}
double calc_panta(point point1, point point2){
return ((double)point1.y - point2.y)/(double)((double)point1.x - point2.x);
}
int combinari(int n, int k){
if(k == 0)
return 1;
if(k>n)
return 0;
return combinari(n-1, k) + combinari(n-1, k-1);
}
int calc(){
int eps = 0.0000001;
int cnt = 0;
int rez = 0;
for(int i=0; i<N-1; i++){
if((pante[i] - pante[i+1]) < eps)
cnt++;
else{
if(cnt == 1)
rez++;
else
if(cnt>1)
rez+= combinari(cnt, 2);
cnt = 0;
}
}
return cnt;
}
int main(){
int rez = 0;
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
citire();
int k = 0;
for(int i=0; i<N; i++){
for(int j=i+1; j<N; j++){
if(P[i].x == P[j].x )
pante[k] = INT_MAX;
else
pante[k] = fabs(calc_panta(P[i], P[j]));
k++;
}
}
sort(pante, pante+k);
cout << calc();
return 0;
}