Cod sursa(job #3349642)
| Utilizator | Data | 1 aprilie 2026 13:48:45 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
int main()
{
std::ifstream i("ciur.in");
std::ofstream o("ciur.out");
int n, s = 0;
i >> n;
n++;
bool p[200001]={};
for (int j = 2; j < n; j++)
if (!p[j])
for (int k = 2; j * k < n; k++)
p[j * k] = 1;
for (int j = 2; j < n; j++)
if (!p[j])
s++;
o << s;
}