Cod sursa(job #546780)
| Utilizator | Data | 5 martie 2011 15:00:36 | |
|---|---|---|---|
| Problema | Indep | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<cstdio>
long long a[510][1010];
int v[510];
int cmmdc(int a, int b)
{
int c;
while(b)
{
c=a%b;
a=b;
b=c;
}
return a;
}
int main()
{
freopen("indep.in","r",stdin);
freopen("indep.out","w",stdout);
int n,i,j,d;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
a[0][0]=1;
for(i=1;i<=n;i++)
{
for(j=0;j<=1000;j++)
{
d=cmmdc(j,v[i]);
a[i][d]+=a[i-1][j];
}
for(j=0;j<=1000;j++)
a[i][j]+=a[i-1][j];
}
printf("%lld",a[n][1]);
return 0;
}
