Pagini recente » Cod sursa (job #373046) | Cod sursa (job #2056010) | Cod sursa (job #1232641) | Cod sursa (job #2440475) | Cod sursa (job #1309714)
#include<fstream>
#include<algorithm>
using namespace std;
ifstream in("trapez.in");
ofstream out("trapez.out");
struct point{
double x, y;
};
const int nmax = 1006;
const double eps = 0.000001;
int n, lvtan = 1, rasp, inf, p;
point v[nmax];
double vtan[nmax * nmax];
double modul(double x)
{
if(x<0)
return -x;
else
return x;
}
int main(){
int player_unu=0;
in>>n;
for(int i = 1; i<=n; i++)
{
in>>v[i].x>>v[i].y;
}
for(int i = 1; i<=n; i++)
{
for(int j = i + 1; j<=n; j++)
{
if(v[i].y!=v[j].y)
{
vtan[lvtan] = (v[i].x - v[j].x) / (v[i].y - v[j].y);
lvtan++;
}
else
{
inf++;
}
}
}
sort(vtan + 1, vtan + lvtan);
vtan[0] = -1000000000;
for(int i = 1; i<lvtan; i++)
{
if(modul(vtan[i] - vtan[i - 1])<eps)
{
p++;
}
else
{
rasp += p * (p - 1) / 2;
p = 1;
}
}
rasp += p * (p - 1) / 2;
rasp += inf * (inf - 1) / 2;
out<<rasp<<'\n';
return player_unu;
}