Pagini recente » Cod sursa (job #215098) | Cod sursa (job #2150435) | Cod sursa (job #1028743) | Cod sursa (job #2018868) | Cod sursa (job #1776029)
#include<fstream>
#include<string.h>
#include<ctype.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<array>
#include<deque>
#include<math.h>
#include<unordered_set>
#include<set>
#include<iomanip>
#include<bitset>
using namespace std;
multimap<double, pair<int, int>>pante;
multimap<double, pair<int, int>>::iterator it,iter;
int n, i,j,nr;
double m;
int puncte[1010][3];
double dist(int p1, int p2)
{
return sqrt((puncte[p1][1] - puncte[p2][1])*(puncte[p1][1] - puncte[p2][1]) + (puncte[p1][2] - puncte[p2][2])*(puncte[p1][2] - puncte[p2][2]));
}
int main()
{
//ifstream f("file.in");
//ofstream g("file.out");
ifstream f("trapez.in");
ofstream g("trapez.out");
f >> n;
for (i = 1; i <= n; i++)
{
f >> puncte[i][1] >> puncte[i][2];
}
for (i = 1; i <= n - 1; i++)
for (j = i + 1; j <= n; j++)
{
if (puncte[j][2] - puncte[i][2] == 0)
{
pante.insert(make_pair(1, make_pair(i, j)));
}
else
if (puncte[j][1] - puncte[i][1] == 0)
{
pante.insert(make_pair(-1, make_pair(i, j)));
}
else
{
m = double(puncte[j][2] - puncte[i][2]) / double(puncte[j][1] - puncte[i][1]);
pante.insert(make_pair(m, make_pair(i, j)));
}
}
for (it = pante.begin(); it != pante.end(); it++)
{
iter = it;
iter++;
while (iter!=pante.end()&&iter->first == it->first&&it->second.first!=iter->second.first&&it->second.first != iter->second.second&&it->second.second != iter->second.first&&it->second.second != iter->second.second)
{
nr++;
iter++;
}
}
g << nr;
return 0;
}