Pagini recente » Cod sursa (job #1468047) | Cod sursa (job #834896) | Cod sursa (job #1240178) | Cod sursa (job #942617) | Cod sursa (job #2144743)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
void ReadFile();
void Sol();
long long factorial(int fact);
const int MaxN = 1001, MaxX = 500000, inf = 0x3f3f3f3f;
int ii[MaxN], jj[MaxN], n, contor = 1;
double panta[MaxX];
int main()
{
ReadFile();
Sol();
}
void ReadFile()
{
fin >> n;
for (int i = 1; i <= n; ++i)
fin >> ii[i] >> jj[i];
}
void Sol()
{
for (int i = 1; i < n; ++i)
for (int j = i + 1; j <= n; ++j)
{
if (ii[i] == ii[j])
panta[contor++] = inf;
else
panta[contor++] = double(jj[i] - jj[j]) / double(ii[i] - ii[j]);
}
sort (panta + 1, panta + contor - 1);
unsigned long long contorr = 0, fact = 0;
for (int i = 1; i < contor - 1; ++i)
{
fact = 1;
for (int j = i; panta[j] == panta[j + 1]; ++j)
{
fact++;
}
if (fact != 1)
contorr += factorial(fact - 1);
}
fout << contorr;
}
long long factorial(int fact)
{
if (fact == 0)
return 0;
return fact + factorial(fact - 1);
}