Cod sursa(job #2151418)
Utilizator | Data | 4 martie 2018 14:21:01 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
#define nmax 2000001
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
long long n,k,ciur[nmax];
void Read()
{
int i,j;
f>>n;
for(i=2; i<=n; i++)
if(ciur[i]==0)
{
k++;
for(j=2; j*i<=n; j++)
ciur[i*j]=1;
}
g<<k;
}
int main()
{
Read();
return 0;
}