Cod sursa(job #2734943)

Utilizator Casian_doispeChiriac Casian Casian_doispe Data 1 aprilie 2021 17:44:40
Problema Trapez Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>

#define MOD 1000000007

using namespace std;

ifstream cin ("trapez.in") ;
ofstream cout("trapez.out") ;

map<pair<int, int>, int > Map ;

int n ;

vector<pair<int, int> > v ;

int main()
{

    cin >> n ;

    for(int f = 1 ; f <= n ; f ++)
    {

        int a, b ;

        cin >> a >> b ;

        v.push_back({a, b}) ;

    }

    for(int f = 0 ; f < v.size() ; f ++)
        for(int e = f + 1 ; e < v.size() ; e ++)
        {

            int a = v[f].first - v[e].first, b = v[f].second - v[e].second ;

            int aux = __gcd(a, b) ;

            //aux = max(aux, 1) ;

            a /= aux ;
            b /= aux ;

            Map[{a, b}] ++ ;


        }

    long long tot = 0 ;

    for(auto f = Map.begin() ; f != Map.end() ; f ++)
        tot += (*f).second * ((*f).second - 1) / 2 ;

    cout << tot ;

    return 0 ;

}