Pagini recente » Cod sursa (job #3274956) | Cod sursa (job #1327947) | Cod sursa (job #2587031) | Cod sursa (job #2914424) | Cod sursa (job #1648978)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct punct
{
long long x,y;
punct(long long x=0, long long y=0):
x(x),y(y)
{
}
bool operator<(const punct &punct2) const
{
if(x==punct2.x)
return y<punct2.y;
else
return x<punct2.x;
}
}puncte[1002];
struct panta
{
long long x,y;
panta(long long x=0, long long y=0):
x(x),y(y)
{
}
bool operator<(const panta &punct2) const
{
return x*punct2.y<punct2.x*y;
}
bool operator==(const panta &punct2) const
{
return x*punct2.y==punct2.x*y;
}
};
bool cmp(punct a, punct b)
{
return a<b;
}
bool cmp2(panta a, panta b)
{
return a<b;
}
long long modul(long long a)
{
if(a<0)
return -a;
return a;
}
int n;
int contor=0;
panta pante[510000];
unsigned long long havem_haur;
unsigned long long ll=1,l2l=2;
void citire()
{
int i,a,b;
fin>>n;
for(i=1;i<=n;i++)
{
fin>>puncte[i].x>>puncte[i].y;
}
}
void creare_pante()
{
int i,j;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
pante[++contor].y=modul(puncte[j].y-puncte[i].y);
pante[contor].x=puncte[j].x-puncte[i].x;
}
}
void rezolvare()
{
int i;
unsigned long long c=ll;
sort(puncte+1,puncte+n+1);
creare_pante();
sort(pante+1,pante+contor+1);
for(i=2;i<=contor;i++)
{
if(pante[i]==pante[i-1])
c+=ll;
else
{
havem_haur+=(c*(c-ll))/l2l;
c=ll;
}
}
}
int main()
{
citire();
rezolvare();
fout<<havem_haur;
return 0;
}