Pagini recente » Rating Giosu Robert (robert.giosu) | Cod sursa (job #1472540) | Cod sursa (job #1503006) | Cod sursa (job #1799120) | Cod sursa (job #811268)
Cod sursa(job #811268)
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#define INF 2147483646
#define eps 1e-14
using namespace std;
class POINT{
private:
int x,y;
public:
POINT(){
x=y=0;
}
void set(int x2,int y2){
x=x2;
y=y2;
}
int getx(){
return x;
}
int gety(){
return y;
}
friend double panta(POINT &a,POINT &b){
if(a.x==b.x){
return INF;
}
return ((double)b.y-a.y)/((double)b.x-a.x);
}
};
vector<POINT> v;
double p[1001000];
bool cmp(double a, double b){
if(a-b<=eps){
return 1;
}
else{
return 0;
}
}
int main(){
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,x,y,i,t=0,j,l=1,lmax=0;
POINT temp;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%d",&x,&y);
temp.set(x,y);
v.push_back(temp);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
p[++t]=panta(v[i],v[j]);
}
}
sort(p+1,p+t+1,cmp);
p[++t]=INF;
for(i=1;i<t;i++){
if(fabs(p[i+1]-p[i])<eps){
l++;
}
else{
lmax+=(l*(l-1)/2);
l=1;
}
}
printf("%d\n",lmax);
return 0;
}