Pagini recente » Cod sursa (job #1296355) | Cod sursa (job #2808756) | Cod sursa (job #1532920) | Cod sursa (job #148832) | Cod sursa (job #1753117)
#include <iostream>
#include<fstream>
using namespace std;
const unsigned int base=1e9;
const unsigned int nmax=1000;
unsigned int n,i,x,modes[1005][1005],c,nr,zeros,j,id,unu[3];
int cmmdc(unsigned int a,unsigned int b)
{
if(a<b) swap(a,b);
while(b!=0)
{
c=a%b;
a=b;
b=c;
}
return a;
}
void add(unsigned int A[],unsigned int B[])
{
if(B[0]>A[0]) A[0]=B[0];
for(id=1;id<=A[0];id++)
{
A[id]+=B[id];
if(A[id]>=base)
{
A[id]-=base;
A[id+1]++;
if(id+1>A[0]) A[0]++;
}
}
}
int main()
{
ifstream f("indep.in");
ofstream g("indep.out");
f>>n;
unu[0]=1;
unu[1]=1;
for(i=1;i<=n;i++)
{
f>>x;
for(j=1;j<=nmax;j++)
{
nr=cmmdc(j,x);
add(modes[nr],modes[j]);
}
add(modes[x],unu);
}
for(i=modes[1][0];i>=1;i--)
{
if(i!=modes[1][0])
{
if(i!=modes[1][0])
{
x=base;
zeros=0;
while(x>modes[1][i])
x/=10,zeros++;
zeros--;
}
for(j=1;j<=zeros;j++) g<<'0';
g<<modes[1][i];
}
for(j=1;j<=zeros;j++) g<<'0';
g<<modes[1][i];
}
if(modes[1][0]==0) g<<'0';
return 0;
}