Cod sursa(job #2216350)
Utilizator | Data | 26 iunie 2018 14:22:58 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int p[2000005],n,cnt;
signed main() {
ifstream fin("ciur.in");
ofstream fout("ciur.out");
fin >> n;
for (int i = 2; i <= n; i++)
if (!p[i]){
cnt++;
int j = 2*i;
while (j <= n){
p[j] = 1;
j += i;
}
}
fout << cnt << endl;
}