Pagini recente » Cod sursa (job #1436108) | Cod sursa (job #1591501) | Cod sursa (job #258778) | Cod sursa (job #1250214) | Cod sursa (job #827365)
Cod sursa(job #827365)
#include <cstdio>
#include <algorithm>
using namespace std;
const int MaxN = 505;
const int MaxV = 1005;
int N, Value[MaxN], MaxValue, DP[MaxV];
inline int GCD(int x, int y) {
while (y != 0) {
int r = x % y;
x = y; y = r;
}
return x;
}
void Solve() {
for (int i = 1; i <= N; ++i) {
for (int PrevValue = 1; PrevValue <= MaxValue; ++PrevValue)
DP[GCD(Value[i], PrevValue)] += DP[PrevValue];
++DP[Value[i]];
}
}
void Read() {
freopen("indep.in", "r", stdin);
scanf("%d", &N);
for (int i = 1; i <= N; ++i) {
scanf("%d", &Value[i]);
MaxValue = max(MaxValue, Value[i]);
}
}
void Print() {
freopen("indep.out", "w", stdout);
printf("%d\n", DP[1]);
}
int main() {
Read();
Solve();
Print();
return 0;
}