Cod sursa(job #1893336)

Utilizator adiXMGemene Adrian adiXM Data 25 februarie 2017 17:03:39
Problema Pairs Scor 20
Compilator cpp Status done
Runda blat11 Marime 0.67 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("pairs.in");
ofstream g("pairs.out");
const int nMax = 100003;
int a[nMax];
int n, mx = 0;
inline void Sol_brut() {
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(__gcd(a[i],a[j]) == 1) {
                //g << a[i] << " " << a[j] << "\n";
                ans++;
            }
        }
    }
    g << ans << "\n";
}
int main()
{
    f >> n;
    for(int i = 1; i <= n; i++) {
        f >> a[i];
        mx = max(mx, a[i]);
    }
    /*if(n <= 2000) {
        Sol_brut();
        return 0;
    }*/
    Sol_brut();
    return 0;
}