Pagini recente » Cod sursa (job #1278793) | Cod sursa (job #2208250) | Cod sursa (job #617571) | Cod sursa (job #2711233) | Cod sursa (job #2710809)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("indep.in");
ofstream fout("indep.out");
const int nmax = 505;
int n, v[nmax], dp[2][1005][505];
void aduna(int *a, int *b){
if (a[0] == 0) a[0] = 1;
if (b[0] == 0) b[0] = 1;
int t = 0;
for (int i = 1; i <= max(a[0], b[0]); ++i){
if (i > a[0]) a[i] = 0;
if (i > b[0]) b[i] = 0;
a[i] = a[i] + b[i] + t;
t = a[i] / 1000;
a[i] %= 1000;
}
a[0] = max(a[0], b[0]);
if (t){
a[++a[0]] = t;
}
}
int main(){
fin >> n;
for (int i = 1; i <= n; ++i){
fin >> v[i];
}
int t = 0;
dp[1 - t][1][0] = dp[1 - t][1][1] = 1;
for (int i = n; i >= 1; --i){
memset(dp[t], 0, sizeof(dp[t]));
for (int j = 0; j <= 1000; ++j){
aduna(dp[t][j], dp[1 - t][j]);
aduna(dp[t][j], dp[1 - t][__gcd(j, v[i])]);
}
t = 1 - t;
}
t = 1 - t;
for (int i = dp[t][0][0]; i >= 1; --i){
if (i != dp[t][0][0]){
if (dp[t][0][0] <= 9){
fout << 00;
}
else if (dp[t][0][0] <= 99){
fout << 0;
}
}
fout << dp[t][0][i];
}
fin.close();
fout.close();
return 0;
}