Pagini recente » Cod sursa (job #86466) | Cod sursa (job #1285826) | Cod sursa (job #2334659) | Cod sursa (job #246831) | Cod sursa (job #1125628)
#include <iostream>
#include <fstream>
#define DN 505
#define LL long long
using namespace std;
LL dp[DN+DN],v[DN];
/// dp[j] = nr de subsiruri divizibile cu j
inline int cmmdc(LL a,LL b){
int c;
for(;b;){
c=a%b;
a=b;
b=c;
}
return a;
}
int main()
{
int n;
ifstream f("indep.in");
ofstream g("indep.out");
f>>n;
// for(int j=1;j<=1000;++j)
// if(v[1]%j == 0)
// dp[1][j]=1;
for(int i=1;i<=n;++i){
LL x;
f>>x;
for(int j=1;j<=1000;++j)
dp[ cmmdc(j,x) ] += dp[j];
dp[x]+=1;
}
g<<dp[1];
return 0;
}