Cod sursa(job #2199399)

Utilizator Eduard663676Ghiuzan Eduard Eduard663676 Data 27 aprilie 2018 15:54:38
Problema Ciurul lui Eratosthenes Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.32 kb
#include <fstream>

using namespace std;

int v[2000005];

int main() {
	ifstream x("ciur.in"); ofstream y("ciur.out");
	int n, count = 0;
	x >> n;
	for (int i = 2; i <= n; i++) {
		if (!v[i]) {
			count++;
			for (int j = 2 * i; j <= n; j += i)
				v[j] = 1;
		}
	}
	y << count;
	x.close(); y.close();
}