Cod sursa(job #1850289)
Utilizator | Data | 18 ianuarie 2017 14:41:03 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bitset<1000010> b;
int n,m,i,k,sol,j;
int main()
{
f>>n;
if(n%2==0)
n--;
m=(n-1)/2;
for(i=1,k=3;k*k<=n;i++,k+=2)
if(!b[i])
for(j=2*i*(i+1);j<=m;j+=k)
b[j]=1;
g<<m-b.count()+1;
return 0;
}