Cod sursa(job #2448666)

Utilizator hellhereHell here hellhere Data 17 august 2019 13:58:14
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.78 kb
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define fi(i,a,b) for (int i = a; i < b; i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define er erase
#define in insert
#define pi pair <int, int>
#define pii pair <pi, pi>
# define sz(x) (int)((x).size())
ll n;
bool p[200005];


int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ifstream cin("ciur.in");
	ofstream cout("ciur.out");
	cin>>n;
	forn(i,1,n)p[i]=0;
	ll ans=0;
	forn(i,2,n){
		if(!p[i]){
		
			ans++;
			for(int j=2*i;j<=n;j+=i)p[j]=1;
		}
		
	}
	cout<<ans;
return 0;
}