Cod sursa(job #1614585)
| Utilizator | Data | 25 februarie 2016 23:59:36 | |
|---|---|---|---|
| Problema | Indep | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("indep.in");
ofstream g("indep.out");
int n,dp[1005],v[1005];
int Cmmdc(int a,int b)
{ int c;
while(b)
{ c=a%b;
a=b; b=c;
}
return a;
}
int main()
{ int i,j,mx=0;
f>>n;
for(i=1;i<=n;i++)
{f>>v[i];
mx=max(mx,v[i]);
}
dp[v[1]]=1;
for(i=2;i<=n;i++)
{
for(j=1;j<=mx;j++)
{dp[Cmmdc(j,v[i])]+=dp[j];
// cout<<dp[j]<<" ";
}
dp[v[i]]++;
// cout<<"\n";
}
g<<dp[1];
return 0;
}
