Pagini recente » Cod sursa (job #3202466) | Cod sursa (job #2558258) | Cod sursa (job #575117) | Cod sursa (job #1101700) | Cod sursa (job #617090)
Cod sursa(job #617090)
#include <cstdio>
int d[1001][101],e[1001][101];
int cmmdc(int x,int y)
{
if (!x)
return y;
else
return cmmdc(y%x,x);
}
int main()
{
int n,x,i,j,k,t,aux;
freopen("indep.in","r",stdin);
freopen("indep.out","w",stdout);
scanf("%d\n",&n);
for (i=1;i<=n;++i)
{
scanf("%d\n",&x);
for (j=1,t=1;j<=e[x][0]||t;++j,t/=1000000000)
e[x][j]=(t+=e[x][j])%1000000000;
e[x][0]=j-1;
for (j=1;j<=1000;++j)
{
aux=cmmdc(x,j);
for (k=1,t=0;k<=e[aux][0]||k<=d[j][0]||t;++k,t/=1000000000)
e[aux][k]=(t+=e[aux][k]+d[j][k])%1000000000;
e[aux][0]=k-1;
}
for (j=1;j<=1000;++j)
for (k=e[j][0];k>=0;--k)
d[j][k]=e[j][k];
}
printf("%d",e[1][e[1][0]]);
for (i=e[1][0]-1;i>0;--i)
{
aux=1;
while (e[1][i]&&aux*e[1][i]<100000000)
{
aux*=10;
printf("0");
}
printf("%d",e[1][i]);
}
printf("\n");
return 0;
}