Pagini recente » Cod sursa (job #613776) | Cod sursa (job #2544495) | Cod sursa (job #1216228) | Cod sursa (job #1980301) | Cod sursa (job #2580640)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
const int N = 500;
const int MAX = 1000;
const int DIGITS = 1000;
int v[5 + N];
template <typename T>
T gcd(T a, T b) {
if(b == 0)
return a;
return gcd(b, a % b);
}
class HugeN {
private:
int v[5 + DIGITS];
public:
HugeN() {
memset(v, 0, sizeof(v));
v[0] = 1;
}
HugeN operator += (const HugeN B) {
int i, t(0);
for(i = 1; i <= v[0] || i <= B.v[0] || t; i++){
v[i] = v[i] + B.v[i] + t;
t = v[i] / 10;
v[i] = v[i] % 10;
}
v[0] = i - 1;
}
HugeN operator += (const int x) {
int i;
v[1] += x;
i = 1;
while(v[i] > 9){
v[i + 1] += v[i] / 10;
v[i] %= 10;
i++;
}
v[0] = i;
}
void Reset() {
memset(v, 0, sizeof(v));
}
void Print() {
int i = v[0];
while(i > 0){
printf("%d", v[i]);
i--;
}
}
};
HugeN dp[2][5 + MAX];
int main() {
freopen("indep.in", "r", stdin);
freopen("indep.out", "w", stdout);
int n, lin;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d", &v[i]);
lin = 0;
dp[lin][v[1]] += 1;
for(int i = 2; i <= n; i++) {
lin = 1 - lin;
for(int j = 1; j <= MAX; j++)
dp[lin][j].Reset();
for(int j = 1; j <= MAX; j++) {
dp[lin][j] += dp[1 - lin][j];
dp[lin][__gcd(v[i], j)] += dp[1 - lin][j];
}
dp[lin][v[i]] += 1;
}
dp[lin][1].Print();
return 0;
}