Pagini recente » Cod sursa (job #2307788) | Cod sursa (job #1268976) | Cod sursa (job #2223223) | Cod sursa (job #94968) | Cod sursa (job #1135874)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
typedef pair<int, int> Punct;
typedef pair<Punct, Punct> Chestie;
Chestie A[510001];
long double Panta[510001];
Punct P[1001];
bool cmp(Chestie X, Chestie Y)
{
return 1LL*(X.first.second - X.second.second)*(Y.first.first - Y.second.first) < 1LL*(Y.first.second - Y.second.second) * (X.first.first - X.second.first );
}
int main()
{
int n;
fin>>n;
for(int i=1;i<=n;i++)
fin>>P[i].first>>P[i].second;
int k = 0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
//A[++k] = make_pair(P[i],P[j]);
if(P[i].first == P[j].first)
Panta[++k] = 2000000001;
else Panta[++k] = 1.0*(P[i].second - P[j].second)/(P[i].first - P[j].first);
}
// sort(A+1,A+1+k,cmp);
sort(Panta+1,Panta+1+k);
//for(int i=1;i<=k;i++)
// fout<<Panta[i]<<'\n';
unsigned long long sol = 0;
for(int i=1;i<=k;i++)
{
int d = 1;
while(
Panta[i] == Panta[i+d]
&& i+d<=k
)
d++;
d--;
sol += (d+1)*d/2;
i = i + d;
}
fout<<sol;
fin.close();
fout.close();
return 0;
}