Pagini recente » Cod sursa (job #1589329) | Cod sursa (job #1428149) | Cod sursa (job #339829) | Cod sursa (job #1014092) | Cod sursa (job #3137920)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
const int dim=2*1e6;
bool CIUR[dim+1];
vector<int>nrPrime;
void ciur(int n)
{
for(int i=4;i<=dim;i+=2)
CIUR[i]=1;
for(int i=3;i*i<=dim;i+=2)
{
if(CIUR[i]==0)
{
for(int j=i*i;j<=dim;j+=2*i)
CIUR[j]=1;
}
}
nrPrime.push_back(2);
for(int i=3;i<=n;i+=2)
if(CIUR[i]==0)nrPrime.push_back(i);
}
int n;
int main()
{
fin>>n;
ciur(n);
//for(auto el : nrPrime)
//fout<<el<<" ";
fout<<nrPrime.size();
}