Cod sursa(job #2012561)

Utilizator sandupetrascoPetrasco Sandu sandupetrasco Data 19 august 2017 00:35:53
Problema Trapez Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define oo 1000000000
#define PII pair <int, int>
   
using namespace std;
int n, rs;
double a[1010], b[1010];
unordered_map < double , int > M;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ifstream cin("trapez.in");
    ofstream cout("trapez.out");
    cin >> n;
    for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	for (int i = 1; i < n; i++)
		for (int j = i + 1; j <= n; j++)
			M[(a[i] - a[j]) / (b[i] - b[j])]++;
	for (auto it : M) rs += it.y * (it.y - 1) / 2;
	cout << rs;
}