Cod sursa(job #1637740)
Utilizator | Data | 7 martie 2016 19:00:28 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{
bool t[2000001];
int n, i=2, j, az=0, k;
f>>n;
while(j<=n)
t[j++]=j;
t[1]=0;
az=n-1;
while(i*i<=n){
for(j=i+i; j<=n; j+=i)
if(j%i==0 and t[j]!=0){
t[j]=0;
az--;}
i++;}
g<<az;
return 0;
}