Cod sursa(job #3313808)

Utilizator PopRadGabPopescu Radu Gabriel PopRadGab Data 6 octombrie 2025 19:49:25
Problema Pairs Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <bits/stdc++.h>
#include <fstream>
using namespace std;

ifstream fin("pairs.in");
ofstream fout("pairs.out");

bool prim(int a,int b){
    int r=0;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a==1;
}

int main(){
    int rez=0;
    int n;
    fin>>n;
    vector<int> x(n);
    for(int i=0;i<n;i++) fin>>x[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(prim(x[i],x[j])) rez++;
        }
    }
    fout<<rez;
    return 0;
}