Cod sursa(job #1513972)
| Utilizator | Data | 30 octombrie 2015 13:27:30 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
#include <string.h>
#define nmax 2000005
using namespace std;
bool v[nmax + 1];
int n;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f >> n;
int nr = 0;
for (int i = 2; i <= n; i++)
if (v[i] == 0)
{
nr++;
for (int j = i * 2; j <= n; j += i) v[j] = 1;
}
g << nr;
return 0;
}
