Cod sursa(job #2906777)
Utilizator | Data | 27 mai 2022 14:20:09 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include<iostream>
#include<fstream>
#define nmax 2000000
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int v[nmax];
int main()
{
int n, cnt = 0;
fin >> n;
for(int i = 2; i <= n; i++)
for(int j = i * i; j <= n; j += i)
v[j] = 1;
for(int i = 2; i <= n; ++i)
if(v[i] == 0)
cnt++;
fout << cnt;
return 0;
}