Cod sursa(job #541784)

Utilizator andunhillMacarescu Sebastian andunhill Data 25 februarie 2011 14:21:05
Problema Light2 Scor 20
Compilator cpp Status done
Runda Romanian Master in Mathematics and Sciences 2011, Ziua 1 Marime 0.4 kb
#include<fstream>
#include<map>
using namespace std;
ifstream f("light2.in");
ofstream g("light2.out");
long long N;
int K;
long long x;
int d[23];
map<long,long>v;
int main()
{	int i,nrb,j;
	f>>N>>K;
	for(i=1,nrb=0;i<=K;i++)
	{	f>>d[i];
		for(j=d[i];j<=N;j+=d[i])
			if(v.find(j)==v.end()) v[j]=++x , nrb++;
			else v.erase(j) , nrb--;
	}
	g<<nrb;
	f.close();
	g.close();
	return 0;
}