Pagini recente » Cod sursa (job #826849) | Cod sursa (job #995733) | Cod sursa (job #2383054) | Cod sursa (job #2613679) | Cod sursa (job #1946054)
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
ifstream in("trapez.in");
ofstream out("trapez.out");
const int oo = 2200000000;
const int NMAX = 1005;
vector <double> slopes;
int N;
struct punct{
int x, y;
}v[NMAX];
double Slope(punct a, punct b){
if(a.x - b.x == 0)return oo;
else
return (double)(a.y - b.y)/(a.x - b.x);
}
void Read(){
in >> N;
for(int i = 1; i <= N; ++i)
in >> v[i].x >> v[i].y;
}
void Solve(){
int sol = 0, k = 1;
for(int i = 1; i <= N; ++i){
for(int j = i + 1; j <= N; ++j)
slopes.push_back(Slope(v[i], v[j]));
}
sort(slopes.begin(), slopes.end());
for(int i = 0; i < slopes.size(); ++i){
if(slopes[i] != oo){
if(fabs(slopes[i] - slopes[i + 1]) <= 0.00000000001)
k++;
else{
sol += k * (k - 1) / 2;
k = 1;
}
}
}
out << sol << "\n";
}
int main(){
Read();
Solve();
return 0;
}