Pagini recente » Cod sursa (job #146359) | Cod sursa (job #3229891) | Cod sursa (job #1390386) | Cod sursa (job #3228375) | Cod sursa (job #160829)
Cod sursa(job #160829)
#include <stdio.h>
#define nmax 505
#define vmax 1005
int n, now;
int a[nmax];
int c[2][vmax];
int cmmdc(int a, int b)
{
if(b == 0) return a;
else return cmmdc(b, a % b);
}
int main()
{
freopen("indep.in", "r", stdin);
freopen("indep.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
now = 0;
for(int i = 1; i < n; i++)
{
now = !now;
c[now][a[i]]++;
for(int j = 0; j <= 1000; j++) c[!now][j] = 0;
for(int j = 0; j <= 1000; j++)
if(c[now][j] != 0)
{
c[!now][j] += c[now][j];
c[!now][cmmdc(j, a[i + 1])] += c[now][j];
}
}
printf("%d\n", c[!now][1]);
return 0;
}