Cod sursa(job #2906784)
| Utilizator | Data | 27 mai 2022 14:28:47 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include<iostream>
#include<fstream>
#define nmax 3000000
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int v[nmax];
int main()
{
int n, cnt = 0;
cin >> n;
for(int i = 2; i * 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++;
cout << cnt;
return 0;
}