Cod sursa(job #3319718)

Utilizator DariuzzHackerPrime Dariuzz Data 2 noiembrie 2025 20:26:18
Problema Triang Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <fstream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
using namespace std;
ifstream cin("triang.in");
ofstream cout("triang.out");
bool egal(double a, double b, double eps = 1e-6) {
    return fabs(a - b) < eps;
}

int main() {
    int n;
    cin >> n;
    vector<pair<double, double > > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    int count = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                double l1 = hypot(v[i].first - v[j].first, v[i].second - v[j].second);
                double l2 = hypot(v[i].first - v[k].first, v[i].second - v[k].second);
                double l3 = hypot(v[j].first - v[k].first, v[j].second - v[k].second);

                if (egal(l1, l2) && egal(l2, l3))
                    count++;
            }
        }
    }

    cout << count << "\n";
    return 0;
}