Cod sursa(job #2439913)

Utilizator miguelMihail Lavric miguel Data 17 iulie 2019 11:10:33
Problema Ciurul lui Eratosthenes Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, cnt;
bool pr[100001];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    ifstream cin("ciur.in");
    ofstream cout("ciur.out");
    cin>>n;
    cnt++;
    for(int i=3; i<=n; i+=2){
        if(pr[i]==0){
            cnt++;
            for(int j=2*i; j<=i*i; j+=i) pr[j]=1;
        }
    }
    cout<<cnt;
}