Cod sursa(job #3380948)
| Utilizator | Data | 3 decembrie 2026 14:51:14 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | cex_03 | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("ciur.in") ;
ofstream fout ("ciur.out") ;
vector < bool > ciur ;
int main()
{
int x ;
fin >> x ;
ciur.resize(x+5) ;
int ans = 0 ;
for ( int i = 2 ; i <= x ; i ++ )
{
if ( ciur[i] == 0 )
{
ans ++ ;
for ( int j = i * 2 ; j <= x ; j += i )
ciur[j] = 1 ;
}
}
fout << ans ;
return 0;
}
