Cod sursa(job #2404657)
| Utilizator | Data | 13 aprilie 2019 11:18:18 | |
|---|---|---|---|
| Problema | Trapez | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
map <long double,int>m;
map <long double,int>::iterator it;
int n,x[1005],y[1005],i,j,s;
long long sol;
long double c;
int main()
{
f>>n;
for(i=1;i<=n;i++)
f>>x[i]>>y[i];
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
if(x[i]==x[j])
m[-10000]++;
else
{c=(long double)(y[j]-y[i])/(x[j]-x[i]);
m[c]++;}
}
for(it=m.begin();it!=m.end();it++)
{
c=it->second;
s=it->first;
sol+=c*(c-1)/2;
}
g<<sol;
return 0;
}
