Cod sursa(job #2916108)

Utilizator alin.gabrielAlin Gabriel Arhip alin.gabriel Data 28 iulie 2022 07:14:14
Problema Trapez Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#include <unordered_map>
#include <iostream>
using namespace std;

int x[1000], y[1000];
unordered_map<double, int> um;

int main() {
    ifstream fin("trapez.in");
    ofstream fout("trapez.out");

    int n, s = 0;
    fin >> n;
    for (int i = 0; i < n; i++)
        fin >> x[i] >> y[i];
    fin.close();

    for (int i = 0 ; i < n; i++)
        for (int j = i + 1; j < n; j++) {
            double m = (y[j] - y[i]) / (double)(x[j] - x[i]);
            cout << "m este: " << fixed << m << "\n";
            um[m]++;
            cout << "um[m] este: " << um[m] << "\n";
        }

    for (auto e : um)
        if (e.second > 1)
            s++;

    cout << "s este: " << s << "\n";

    fout << s;
    fout.close();
    return 0;
}