Cod sursa(job #541567)

Utilizator Teodor94Teodor Plop Teodor94 Data 25 februarie 2011 12:09:36
Problema Light2 Scor 10
Compilator cpp Status done
Runda Romanian Master in Mathematics and Sciences 2011, Ziua 1 Marime 0.42 kb
#include<cstdio>

const int N=1000000;

int n,k,nr;
bool fr[N];

void citire()
{
	freopen("light2.in","r",stdin);
	freopen("light2.out","w",stdout);
	scanf("%d%d",&n,&k);
}

void rez()
{
	int x;
	for (int i=1;i<=k;++i)
	{
		scanf("%d",&x);
		for (int j=x;j<=n;j+=x)
			fr[j]=!fr[j];
	}
	for (int i=1;i<=n;++i)
		if (fr[i])
			++nr;
	printf("%d\n",nr);
}

int main()
{
	citire();
	rez();
	return 0;
}