Cod sursa(job #1426405)
Utilizator | Data | 29 aprilie 2015 17:37:19 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
# define nmax 2000000
using namespace std;
long long n,i,j,ct;
bool w[nmax];
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
for(i=2;i<=n;i++)
if (w[i]==false)
{
ct++;
for(j=i*i;j<=n;j=j+i)
w[j]=true;
}
g<<ct;
f.close();
g.close();
return 0;
}