Pagini recente » Cod sursa (job #679362) | Cod sursa (job #2311910) | Cod sursa (job #553061) | Borderou de evaluare (job #2022797) | Cod sursa (job #2705230)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("indep.in");
ofstream fout("indep.out");
int n, el;
vector <int> pd[2][1005];
void aduna(vector <int> &a, vector <int> b) {
if (a.size() < b.size())
swap(a, b);
int rest = 0;
for (int i = 0; i < a.size() || rest > 0; ++i) {
if (i >= a.size()) {
a.push_back(rest % 10);
rest /= 10;
continue;
}
if (i < b.size())
a[i] += b[i];
a[i] += rest;
rest = a[i] / 10;
a[i] %= 10;
}
return;
}
int main() {
fin >> n;
bool turn = false;
for (int i = 1; i <= n; ++i) {
fin >> el;
for (int j = 1; j <= 1000; ++j)
pd[turn][j].clear();
for (int j = 1; j <= 1000; ++j) {
int c = __gcd(el, j);
if (pd[turn][c].empty())
pd[turn][j] = pd[!turn][j];
else
aduna(pd[turn][j], pd[!turn][j]);
aduna(pd[turn][c], pd[!turn][j]);
}
if (pd[turn][el].empty())
pd[turn][el] = {1};
else
aduna(pd[turn][el], {1});
turn = !turn;
}
for (int i = pd[!turn][1].size() - 1; i >= 0; --i)
fout << pd[!turn][1][i];
return 0;
}