Cod sursa(job #2100256)

Utilizator marcudanfDaniel Marcu marcudanf Data 5 ianuarie 2018 14:15:30
Problema Ciurul lui Eratosthenes Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.28 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("ciur.in");
ofstream fout("ciur.out");

int n, nr;
bool p[2000005];

int main(){
	fin>> n ;
	for(int i = 2; i <=n; i++)
		if(!p[i]){
			nr++;
			for(int j = i + 1; j <= n; j += i)
				p[j] = 1;
		}
	fout<< nr ;
	return 0;
}