Pagini recente » Cod sursa (job #951851) | Cod sursa (job #3207949) | Cod sursa (job #924897) | Cod sursa (job #2648271) | Cod sursa (job #2381837)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("indep.in");
ofstream fout("indep.out");
int n, x;
int one[200], dp[1002][200];
void aduna (int a[], int b[]) {
int t = 0, aux;
a[0] = max(a[0], b[0]);
for (int i = 1; i <= max(a[0], b[0]); i++) {
aux = a[i] + b[i] + t;
a[i] = aux % 10;
t = aux / 10;
}
if (t)
a[++a[0]] = t;
}
int gcd (int a, int b) {
int r;
while (b) {
r = a % b;
a = b;
b = r;
}
return a;
}
int main ()
{
fin >> n;
one[0] = one[1] = 1;
for (int i = 1; i <= n; i++) {
fin >> x;
for (int j = 1; j <= 1000; j++) {
aduna(dp[gcd(x, j)], dp[j]);
}
aduna(dp[x], one);
}
for (int i = dp[1][0]; i >= 1; i--)
fout << dp[1][i];
return 0;
}