Pagini recente » Cod sursa (job #2891288) | Cod sursa (job #1182482) | Cod sursa (job #2601186) | Cod sursa (job #37362) | Cod sursa (job #3129800)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ifstream fin("indep.in");
ofstream fout("indep.out");
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int n; fin >> n;
vector<bool> isPrime(1001, true);
for(int i = 2; i <= 1000; ++i){
if(!isPrime[i]) continue;
for(int j = 2; i*j <= 1000; ++j)
isPrime[i*j] = false;
}
vector<vector<int>> dp(n+1, vector<int>(1001, 0));
int _max = 0;
for(int i = 0, x; i < n; ++i){
fin >> x; _max = max(_max, x);
for(int j = 2; j <= x; ++j){
//cout << j << " ";
if(__gcd(x, j) != 1)
dp[i+1][j] = dp[i][j] + 1;//, cout << "added! ";
else
dp[i+1][j] = dp[i][j];
}
for(int j = x+1; j <= _max; ++j)
dp[i+1][j] = dp[i][j];
}
//for(int i = 2; i <= 6; ++i)
// cout << i << ": " << dp[n][i] << "\n";
ll total = (1LL << (1LL*n)) - n - 1;
for(int i = 2; i < 1000; ++i)
if(isPrime[i])
total -= (1LL << dp[n][i]) - dp[n][i] - 1;
fout << total;
}