Cod sursa(job #2705097)

Utilizator gasparrobert95Gaspar Robert Andrei gasparrobert95 Data 11 februarie 2021 21:33:46
Problema Indep Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 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 <= min(el, (ll)1000); ++j) {
            ll c = __gcd(el, j);
            pd[i][c] += pd[i - 1][j] + pd[i - 1][c];
        }
        ++pd[i][el];
    }
    fout << pd[n][1];
    return 0;
}