Cod sursa(job #2545728)

Utilizator arckerDolteanu Gabriel arcker Data 13 februarie 2020 14:28:55
Problema Triang Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.03 kb
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
 
int main(){
    ifstream cin("triang.in");
    ofstream cout("triang.out");
    int n, ans = 0;
    double eq = 0.001, hp1, hp2, hp3, hp4, hp5;
    cin >> n;
    vector<pair<double, double> > v(n);
    for(int i = 0; i < n; ++i)
        cin >> v[i].x >> v[i].y;
    
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            for(int k = j + 1; k < n; ++k){
                hp1 = v[i].x - v[j].x;
                hp2 = v[i].y - v[j].y;
                hp3 = (hp1 * hp1) + (hp2 * hp2);
 
                hp1 = v[i].x - v[k].x;
                hp2 = v[i].y - v[k].y;
                hp4 = (hp1 * hp1) + (hp2 * hp2);
 
                hp1 = v[j].x - v[k].x;
                hp2 = v[j].y - v[k].y;
                hp5 = (hp1 * hp1) + (hp2 * hp2);
 
                if((abs(hp3 - hp4) < eq) && (abs(hp3 - hp5) < eq) && (abs(hp4 - hp5) < eq))
                    ++ans;
            }
        }
    }
    cout << ans << '\n';
    cin.close(), cout.close();
}