Cod sursa(job #2169991)
Utilizator | Data | 14 martie 2018 20:23:58 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
long long n,i,ct=0,k;f>>n;bool v[2000001]={0};
for(i=2;i<=n;i++)
{
if(v[i]==0)ct++;
for(k=2;k<=n/i+1;k++)
v[k*i]=1;
}
g<<ct<<"\n";
f.close ();
g.close ();
}