Pagini recente » Diferente pentru utilizator/armandnm intre reviziile 8 si 9 | Borderou de evaluare (job #606204) | Cod sursa (job #2778827) | Cod sursa (job #1771087)
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
double abs(double x)
{
if(x>=0) return x;
else return -(x);
}
int main()
{
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
int n;
scanf("%d", &n);
vector <int> x, y;
for(int i=1; i<=n; i++)
{
int X, Y;
scanf("%d%d", &X, &Y);
x.push_back(X);
y.push_back(Y);
}
vector <double> v;
for(int i=1; i<n; i++)
for(int j=i+1; j<=n; j++)
{
if(y[i]-y[j])
{
double tan=abs(x[i]-x[j]+0.1-0.1)/abs(y[i]-y[j]+0.1-0.1);
v.push_back(tan);
}
else v.push_back(-1);
}
sort(v.begin(), v.end());
int k=0, ans;
vector <double> :: iterator it;
for(it=v.begin()+1; it<=v.end(); it++)
{
if(*it != *(it-1))
{
ans+=k*(k-1)/2;
k=1;
}
else k++;
}
printf("%d", ans);
}