Cod sursa(job #2418749)
| Utilizator | Data | 6 mai 2019 09:39:33 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define nmax 2000005
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, sol, i, j;
char c[nmax];
int main()
{
fin >> n;
for(i = 2; i <= n; ++i)
c[i] = 0;
for(i = 2; i <= n; ++i)
if(c[i] == 0)
{
sol++;
for(j = i + i; j <= n; j += i)
c[j] = 1;
}
fout << sol;
return 0;
}
