Pagini recente » Cod sursa (job #1812815) | Cod sursa (job #1472639) | Cod sursa (job #1342873)
#include <bits/stdc++.h>
using namespace std;
const int Vmax = 1000;
int dp[2][Vmax + 1];
int N;
int main()
{
ifstream in("indep.in");
ofstream out("indep.out");
ios_base::sync_with_stdio(false);
in >> N;
for ( int i = 1; i <= N; ++i )
{
int value;
int cr = i & 1;
int pr = cr ^ 1;
in >> value;
dp[cr][value]++;
for ( int j = 1; j <= Vmax; ++j )
{
int GCD = __gcd(j, value);
dp[cr][GCD] += dp[pr][j];
}
for ( int j = 1; j <= Vmax; ++j )
dp[pr][j] = dp[cr][j];
}
out << dp[N & 1][1] << "\n";
return 0;
}