Cod sursa(job #2734955)

Utilizator Casian_doispeChiriac Casian Casian_doispe Data 1 aprilie 2021 17:54:03
Problema Trapez Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.22 kb
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>

#define MOD 1000000007

using namespace std;

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

unordered_map<unsigned long long, int > Map ;

int n ;

vector<pair<int, int> > v ;

vector<unsigned long long> vv ;

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 ;

            vv.push_back(a * 100000000000 + b) ;


        }

    sort(vv.begin(), vv.end()) ;

    long long tot = 0 ;

    int curent = 1 ;

    for(int f = 1 ; f < vv.size() ; f ++)
    {

        if(vv[f] == vv[f - 1])curent ++ ;
            else
            {

                tot += curent * (curent - 1) / 2 ;

                curent = 1 ;

            }

    }

    cout << tot ;

    return 0 ;

}