Cod sursa(job #3220543)

Utilizator unomMirel Costel unom Data 4 aprilie 2024 07:09:20
Problema Puteri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.99 kb
#include <fstream>
#include <algorithm>

using namespace std;

struct el
{
    int a, b, c;
};

ifstream in("puteri.in");
ofstream out("puteri.out");
int n, ans;
int w[67][67][67];
el v[100005];

int main()
{
    in>>n;

    for(int i = 1; i<=n; i++)
    {
        in>>v[i].a>>v[i].b>>v[i].c;
    }

    for(int i = 0; i<=64; i++)
    {
        for(int j = 0; j<=64; j++)
        {
            for(int k = 0; k<=64; k++)
            {
                if(__gcd(__gcd(i, j), k) > 1)
                {
                    w[i][j][k] = 1;
                }
            }
        }
    }

    int a, b, c;
    for(int i = 1; i<=n; i++)
    {
        for(int j = i+1; j<=n; j++)
        {
            a = v[i].a + v[j].a;
            b = v[i].b + v[j].b;
            c = v[i].c + v[j].c;

            if(w[a][b][c] == 1)
            {
                //out<<i<<" -> "<<j<<'\n';
                ans++;
            }
        }
    }

    out<<ans;

    return 0;
}