Cod sursa(job #1922315)
| Utilizator | Data | 10 martie 2017 16:57:37 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
ifstream fin( "ciur.in" );
ofstream fout( "ciur.out" );
char v[2000010];
int i,j,n,m,ans;
int main()
{
fin>>n;
for( i = 2 ; i <= n ; i++ )
{
if( v[ i ] == 0 )
{
for( j = i + i ; j <= n ; j += i )
v[ j ] = 1;
++ans;
}
}
fout<<ans;
return 0;
}
