Pagini recente » Cod sursa (job #2186393) | Cod sursa (job #1208033) | Cod sursa (job #361037) | Cod sursa (job #2189330) | Cod sursa (job #2580649)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <fstream>
#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 = 100;
int v[5 + N];
ifstream in ("indep.in");
ofstream out ("indep.out");
inline int gcd(int a, int b) {
if(b == 0)
return a;
return gcd(b, a % b);
}
class HugeN {
private:
int v[5 + DIGITS];
public:
HugeN SetValue(int value){
int i;
for(i = 1; value > 0; i++, value /= 10)
v[i] = value % 10;
v[0] = i - 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;
}
void Reset() {
for(int i = v[0]; i >= 0; i--)
v[i] = 0;
v[0] = 1;
}
void Print() {
int i = v[0];
while(i > 0){
out << v[i];
i--;
}
}
};
HugeN dp[2][5 + MAX];
HugeN One;
int main() {
//freopen("indep.in", "r", stdin);
//freopen("indep.out", "w", stdout);
int n, lin;
in >> n;
for(int i = 1; i <= n; i++)
in >> v[i];
One.SetValue(1);
lin = 0;
dp[lin][v[1]] += One;
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]] += One;
}
dp[lin][1].Print();
return 0;
}