Cod sursa(job #540309)

Utilizator filipbFilip Cristian Buruiana filipb Data 23 februarie 2011 21:19:52
Problema Light2 Scor Ascuns
Compilator cpp Status done
Runda Marime 0.61 kb
#include <cstdio>
#include <map>

using namespace std;

#define ll long long

ll N;
int K, d[32];
map<ll, bool> hash;

int main()
{
    freopen("light2.in", "r", stdin);
    freopen("light2.out", "w", stdout);

    scanf("%lld%d", &N, &K);
    for (int i = 1; i <= K; ++i)
        scanf("%d", &d[i]);
    
    for (int i = 1; i <= K; ++i)
        for (int j = d[i]; j <= N; j += d[i])
            hash[j] = !hash[j];
    ll sol = 0;
    for (map<ll, bool>::iterator it = hash.begin(); it != hash.end(); ++it)
        sol += (it->second == true);
    printf("%lld\n", sol);
    
    return 0;
}