Cod sursa(job #2253807)
Utilizator | Data | 4 octombrie 2018 14:22:36 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bool x[2000000];
long long n, k;
int main()
{
f >> n;
for (long long i=2; i<=n;i++)
if (x[i]==0)
{
k++;
for (long long j = i*i; j<=n; j+=i)
x[j]=1;
}
g << k;
}