Cod sursa(job #1932588)
Utilizator | Data | 19 martie 2017 21:51:38 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#include <vector>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{
int n,i,s=0;
vector <int>v(2000001,0);
f>>n;
for(int i=3;i<=n;i+=2)
for(int j=3*i;j<=n;j+=2*i)
{
v[j]=1;
}
for(int i=3;i<=n;i+=2)
if(v[i]==0)
s++;
g<<s+1;
f.close();
g.close();
}