Cod sursa(job #3139085)
Utilizator | Data | 24 iunie 2023 19:55:38 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
int x, total, limit;
short v[2000002];
int main() {
ifstream fin("ciur.in");
ofstream fout("ciur.out");
fin >> x;
limit = x / 2;
for(int i = 2; i <= limit; i++) {
if (v[x] == 0) {
total ++;
for(int j = x; j <= limit; j += x) {
v[j] = 1;
}
}
}
fout << total << std::endl;
fin.close();
fout.close();
return 0;
}