Cod sursa(job #1559825)
Utilizator | Data | 31 decembrie 2015 16:47:37 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
int c[2000001];
int main() {
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 2; i * i <= n; ++i)
if (!c[i])
for (int j = i * i; j <= n; j += i)
c[j] = 1;
int res = 0;
for (int i = 2; i <= n; ++i)
if (!c[i])
++res;
printf("%d", res);
}