Cod sursa(job #2545631)

Utilizator arckerDolteanu Gabriel arcker Data 13 februarie 2020 12:40:18
Problema Triang Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.12 kb
#include <bits/stdc++.h>
#define TN 10000
using namespace std;

struct pct{
    double x, y;
}v[1502];

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;
    for(int i = 1; i <= n; ++i){
        cin >> v[i].x >> v[i].y;
        v[i].x += TN, v[i].y += TN;
    }
    for(int i = 1; i <= n; ++i){
        for(int j = i + 1; j <= n; ++j){
            for(int k = j + 1; k <= n; ++k){
                hp1 = abs(v[i].x - v[j].x);
                hp2 = abs(v[i].y - v[j].y);
                hp3 = (hp1 * hp1) + (hp2 * hp2);

                hp1 = abs(v[i].x - v[k].x);
                hp2 = abs(v[i].y - v[k].y);
                hp4 = (hp1 * hp1) + (hp2 * hp2);

                hp1 = abs(v[j].x - v[k].x);
                hp2 = abs(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();
}