Cod sursa(job #2765486)

Utilizator OvidRata Ovidiu Ovid Data 27 iulie 2021 10:37:13
Problema Indep Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1 kb
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


ifstream fin("indep.in"); ofstream fout("indep.out");
#define cin fin
#define cout fout

int t, n, m, k, a[300010], q, l, r;

int nr[1001][2];

int32_t main(){
INIT
//cout<<__gcd(0, 20)<<"\n";
cin>>n;
nr[0][0]=1;
for(int i=1; i<=n; i++){
    cin>>a[i];
    for(int gcd=0; gcd<=1000; gcd++){
        nr[gcd][1]+=nr[gcd][0];
        nr[__gcd(a[i], gcd) ][1]+=nr[gcd][0];
    }
    for(int gcd=0; gcd<=1000; gcd++){
        nr[gcd][0]=nr[gcd][1];
        nr[gcd][1]=0;
    }
    /*
    for(int gcd=0; gcd<=6; gcd++){
        cout<<nr[gcd][0]<<" ";
    }
    cout<<"\n";
    */
}
cout<<nr[1][0];


return 0;
}