Cod sursa(job #3282701)

Utilizator stefanrotaruRotaru Stefan-Florin stefanrotaru Data 6 martie 2025 14:41:30
Problema Pairs Scor 0
Compilator cpp-64 Status done
Runda oji_go_11_12 Marime 0.63 kb
#include <fstream>
#include <vector>

using namespace std;

ifstream f("pairs.in");
ofstream g("pairs.out");

int n, x, ans, fr[100005];

vector <int> a;

inline int cmmdc(int a, int b)
{
    while (b) {
        int r = a % b;
        a = b;
        b = r;
    }

    return a;
}

int main()
{
    for (int i = 1; i <= 100005; ++i) {
        a.push_back(i);
    }

    f >> n;

    while (n--) {
        f >> x;

        for (auto it : a) {
            if (cmmdc(x, it) == 1) {
                ans += fr[x ^ it];
            }
        }

        fr[x]++;
    }

    g << ans;

    return 0;
}