Pagini recente » Cod sursa (job #2690415) | Cod sursa (job #3142677) | Cod sursa (job #884999) | Cod sursa (job #2229325) | Cod sursa (job #2926408)
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
using ll = long long;
using namespace std;
const int NMAX = 505;
const int GCDMAX = 1005;
/*******************************/
// INPUT / OUTPUT
ifstream f("indep.in");
ofstream g("indep.out");
/*******************************/
/// GLOBAL DECLARATIONS
int N;
int v[NMAX], x[GCDMAX][GCDMAX];
ll dp[NMAX][GCDMAX];
/*******************************/
/// FUNCTIONS
void ReadInput();
void Solution();
void Output();
/*******************************/
///-------------------------------------
inline void ReadInput()
{
f >> N;
for (int i = 1 ; i <= N ; ++ i)
{
f >> v[i];
}
}
///-------------------------------------
inline void Solution()
{
for (int i = 1 ; i < GCDMAX ; ++ i)
{
for (int j = 1 ; j < GCDMAX ; ++ j)
{
x[i][j] = __gcd(i, j);
}
}
dp[1][v[1]] = 1;
for (int i = 2 ; i <= N ; ++ i)
{
for (int gcd = 1 ; gcd < GCDMAX ; ++ gcd)
{
dp[i][gcd] += dp[i - 1][gcd];
dp[i][x[gcd][v[i]]] += dp[i - 1][gcd];
}
}
}
///-------------------------------------
inline void Output()
{
g << dp[N][1];
}
///-------------------------------------
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ReadInput();
Solution();
Output();
return 0;
}