Cod sursa(job #1337518)

Utilizator wGEORGEWGeorge Cioti wGEORGEW Data 9 februarie 2015 09:59:00
Problema Puteri Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <cstdio>
#include <vector>
 
#define NMAX 100007
 
using namespace std;
 
int a[NMAX], b[NMAX], c[NMAX];
int n, Ans;
 
inline int cmmdc(int a, int b){
    if(!b)
        return a;
    return cmmdc(b, a % b);
}
 
int main(){
    freopen("puteri.in", "r", stdin);
    freopen("puteri.out", "w", stdout);
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j){
            int k = cmmdc(a[i] + a[j], b[i] + b[j]);
            k = cmmdc(k, c[i] + c[j]);
            if(k > 1)
                ++Ans;
        }
    printf("%d", Ans);
}