Cod sursa(job #1290879)

Utilizator Darius15Darius Pop Darius15 Data 11 decembrie 2014 21:51:08
Problema Puteri Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>

using namespace std;
ifstream f("puteri.in");
ofstream g("puteri.out");
struct poz{int a,b,c;};
poz v[100001];
int n,i,x,y,z,j,c;
long long sol;
int cmmdc(int x,int y)
{
    int r;
    if (y==0) return x;
    do
    {
        r=x%y;
        x=y,y=r;
    }
    while (y);
    return x;
}
int main()
{
    f>>n;
    for (i=1;i<=n;i++)
        f>>v[i].a>>v[i].b>>v[i].c;
    for (i=1;i<=n;i++)
         for (j=i+1;j<=n;j++)
    {
        x=v[i].a+v[j].a,y=v[i].b+v[j].b,z=v[i].c+v[j].c;
        if (cmmdc(x,cmmdc(y,z))!=1) sol++;
    }
    g<<sol;
    return 0;
}