Cod sursa(job #2710635)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 22 februarie 2021 20:04:23
Problema Indep Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <bits/stdc++.h>
#define int unsigned long long

using namespace std;

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

int N, dp[2][1001], ind = 1;

int32_t main() {
    fin >> N;
    dp[0][0] = 1;
    for(int i = 1; i <= N; ++i, ind ^= 1) {
        int x;
        fin >> x;
        for(int j = 0; j < 1001; ++j)
            dp[ind][j] = dp[!ind][j];
        for(int j = 0; j < 1001; ++j)
            dp[ind][__gcd(j, x)] += dp[!ind][j];
    }
    fout << dp[!ind][1] << '\n';
}