Cod sursa(job #2208713)

Utilizator aurelionutAurel Popa aurelionut Data 31 mai 2018 00:44:18
Problema Economie Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>
#include <vector>

using namespace std;

const int NMAX = 1010;
const int VALMAX = 50010;
int n;
int ciur[VALMAX];
vector <int> a;

int main()
{
	ifstream fin("economie.in");
	ofstream fout("economie.out");
	fin >> n;
	int x;
	for (int i = 1;i <= n;++i)
	{
		fin >> x;
		ciur[x] = 2;
	}
	for (int i = 1;i < VALMAX;++i)
		if (ciur[i] != 1)
		{
			if (ciur[i] == 2)
				a.push_back(i);
			for (int j = 2 * i;j < VALMAX;j += i)
				ciur[j] = 1;
		}
	fout << (int)a.size() << "\n";
	for (int i : a)
		fout << i << "\n";
	fin.close();
	fout.close();
	return 0;
}