Cod sursa(job #2034977)

Utilizator randiboyPucani Catalin randiboy Data 8 octombrie 2017 18:49:12
Problema Ciurul lui Eratosthenes Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.48 kb
// ConsoleApplication22.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");

int n,cnt;
bool mark[2000001];

void verif()
{
	int i,j;
	for (i = 2; i <=n; i++)
	{
		for (j = i+i; j <= n; j+=i)
		{
			mark[j] = 1;
		}
		if (mark[i] == 0)
			cnt++;
	}
}

int main()
{
	int i;
	f >> n;
	verif();
	g << cnt ;
    return 0;
}