Cod sursa(job #2034956)
| Utilizator | Data | 8 octombrie 2017 18:23:14 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 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 <= sqrt(n); i++)
{
for (j = i; j*i <= n; j++)
{
mark[i*j] = 1;
}
}
}
int main()
{
int i;
f >> n;
verif();
for (i = 2; i <= n; i++)
if (mark[i] == 0)
cnt++;
g << cnt << endl;
return 0;
}
