Cod sursa(job #2705221)

Utilizator gasparrobert95Gaspar Robert Andrei gasparrobert95 Data 12 februarie 2021 10:31:34
Problema Indep Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("indep.in");
ofstream fout("indep.out");
ll n, el, pd[505][1005];

int main() {
    fin >> n;
    for (int i = 1; i <= n; ++i) {
        fin >> el;
        for (ll j = 1; j <= 1000; ++j) {
            ll c = __gcd(el, j);
            if (pd[i][c] == 0)
                pd[i][c] = pd[i - 1][c];
            pd[i][c] += pd[i - 1][j];
        }
        for (int j = 1; j <= 1000; ++j)
            if (pd[i][j] == 0)
                pd[i][j] = pd[i - 1][j];
        ++pd[i][el];
    }
    fout << pd[n][1];
    return 0;
}