Cod sursa(job #2868054)
Utilizator | Data | 10 martie 2022 18:29:23 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream o("ciur.out");
int main()
{
int ciur[1001] = {0},k=0;
for (int i = 2; i <= 1000; i++) {
if (ciur[i] == 0) {
for (int j = 2 * i; j <= 1000; j += i) {
ciur[j] = 1;
}
}
}
for (int i = 2; i <= 1000; i++) {
if (ciur[i] == 0) {
k++;
}
}
o << k;
return 0;
}