Pagini recente » Cod sursa (job #251794) | Cod sursa (job #2849250) | Cod sursa (job #556262) | Cod sursa (job #2160872) | Cod sursa (job #2824278)
#include <bits/stdc++.h>
using namespace std;
inline void Open(const string Name) {
#ifndef ONLINE_JUDGE
(void)!freopen((Name + ".in").c_str(), "r", stdin);
(void)!freopen((Name + ".out").c_str(), "w", stdout);
#endif
}
const int base = 1000000000;
const int base_digits = 9;
struct BigInt {
int a[1001];
int sign;
void trim() {
while(a[0] > 0 && a[a[0]] == 0) a[0]--;
if(a[0] == 0) sign = 1;
}
BigInt() :
sign(1) {
}
BigInt(unsigned long long v) {
*this = v;
}
void operator = (unsigned long long v) {
a[0] = 0, sign = 1;
if(v < 0) sign = - sign, v = -v;
for(;v > 0;v = v / base)
a[++a[0]] = (v % base);
}
BigInt operator + (const BigInt &v) const {
BigInt res = v;
for(int i = 1, carry = 0;i <= max(a[0], v.a[0]) || carry;i++) {
if(i == res.a[0] + 1)
res.a[++res.a[0]] = 0;
res.a[i] += carry + (i <= a[0]? a[i] : 0);
carry = res.a[i] >= base;
if(carry) res.a[i] -= base;
}
return res;
}
friend ostream &operator << (ostream &stream, const BigInt &v) {
if (v.sign == -1) stream << '-';
stream << (v.a[0] == 0? 0 : v.a[v.a[0]]);
for (int i = v.a[0] - 1;i >= 1;i--)
stream << setw(base_digits) << setfill('0') << v.a[i];
return stream;
}
};
BigInt dp[2][1001];
int a[501];
int N;
void solve() {
cin >> N, dp[0][0] = 1;
for(int i = 1;i <= N;i++) {
cin >> a[i];
for(int j = 0;j <= 1000;j++)
dp[i & 1][j] = dp[(i - 1) & 1][j];
for(int j = 0;j <= 1000;j++)
dp[i & 1][__gcd(j, a[i])] = dp[i & 1][__gcd(j, a[i])] + dp[(i - 1) & 1][j];
}
cout << dp[N & 1][1];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Open("indep");
int T = 1;
for(;T;T--) {
solve();
}
return 0;
}