Cod sursa(job #2573749)
Utilizator | Data | 5 martie 2020 18:59:48 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
#include <cstring>
# define pb push_back
#define nmax 100002
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
string a,b;
int n,k,i,d;
bool ciur[2000004];
int main()
{
f>>n;
for(d=2;d*d<=n;d++)
if(ciur[d]==0)
for(i=d*d;i<=n;i+=d)
ciur[i]=1;
for(i=2;i<=n;i++)
if(!ciur[i])
k++;
g<<k;
return 0;
}