Cod sursa(job #3349738)
| Utilizator | Data | 2 aprilie 2026 12:38:23 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
int main() {
int n, s=0;
std::ifstream("ciur.in") >> n;
bool * p = new bool[n + 1];
for(int i = 2; i <= n; i++)
p[i] = true;
for(int i=2; i <= n; i++)
if(p[i])
for(int j = 2; i * j <= n; j++)
p[i * j] = false;
for(int i = 2; i <= n; i++)
s += p[i];
std::ofstream("ciur.out") << s;
}