Cod sursa(job #2199398)
| Utilizator | Data | 27 aprilie 2018 15:53:11 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
int v[2000001];
int main() {
ifstream x("ciur.in"); ofstream y("ciur.out");
int n, count = 0;
x >> n;
for (int i = 2; i <= n; i++) {
if (!v[i]) {
count++;
for (int j = 2 * i; j <= n; j += i)
v[j] = 1;
}
}
y << count;
x.close(); y.close();
}