Cod sursa(job #541463)

Utilizator valentina506Moraru Valentina valentina506 Data 25 februarie 2011 11:35:30
Problema Light2 Scor 10
Compilator cpp Status done
Runda Romanian Master in Mathematics and Sciences 2011, Ziua 1 Marime 0.35 kb
#include<fstream>
using namespace std;
unsigned long long n,i,j,nr,k,x;
bool ok[1000000000];
int main()
{
	ifstream f("light2.in");
	ofstream g("light2.out");
	f>>n>>k;
	for(i=1;i<=k;i++)
	{
		f>>x;
		for(j=x;j<=n;j+=x)
			if(!ok[j])
			{
				nr++;
				ok[j]=1;
			}
			else
			{
				nr--;
				ok[j]=0;
			}
	}
	g<<nr;
	return 0;

}