Cod sursa(job #1326329)
Utilizator | Data | 25 ianuarie 2015 10:39:13 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bool p[200002];
int main()
{
int n;
f>>n;
int c=0;
for(int i = 2; i <= n; ++i)
if(!p[i])
{
for(int j = i+i; j <= n; j+=i)
p[j] = 1;
c++;
}
g<<c;
}