Cod sursa(job #2986811)
Utilizator | Ilie Dumitru Ilie_Mity | Data | 1 martie 2023 11:41:24 |
---|---|---|---|
Problema | Indep | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
//Ilie Dumitru
#include<cstdio>
#include<algorithm>
const int NMAX=512;
const int VALMAX=1024;
int N, cnt[VALMAX];
int v[NMAX];
int main()
{
FILE* f=fopen("indep.in", "r"), *g=fopen("indep.out", "w");
int i, j, d;
fscanf(f, "%d", &N);
for(i=0;i<N;++i)
fscanf(f, "%d", v+i);
cnt[v[0]]=1;
for(i=1;i<N;++i)
{
for(j=1;j<VALMAX;++j)
{
d=std::__gcd(v[i], j);
cnt[d]+=cnt[j];
}
++cnt[v[i]];
}
fprintf(g, "%d\n", cnt[1]);
fclose(f);
fclose(g);
return 0;
}