Cod sursa(job #3220544)

Utilizator unomMirel Costel unom Data 4 aprilie 2024 07:10:17
Problema Puteri Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1 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[130][130][130];
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<=128; i++)
    {
        for(int j = 0; j<=128; j++)
        {
            for(int k = 0; k<=128; 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;
}