Cod sursa(job #2689774)
Utilizator | Data | 22 decembrie 2020 02:25:11 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bool v[2000005];
int main(){
ll n;
fin>>n;
int counter = 1;
for(int i = 3; i <= n; i+=2) {
if(!v[i]) {
counter++;
v[i] = 1;
for(int j = i+i; j <= n; j+=i){
v[j] = 1;
}
}
}
fout<<counter;
}