Pagini recente » Cod sursa (job #2483309) | Cod sursa (job #170193) | Cod sursa (job #1777799) | Cod sursa (job #2239277) | Cod sursa (job #786990)
Cod sursa(job #786990)
#include<fstream>
#include<malloc.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
#define NMAX 2000000
int n = 0,nr = 0;
short a[NMAX];
void eratosthenes()
{
for(int i = 4; i <= n; i+=2)
a[i] = 1;
nr = 1;
for(int i = 3; i <= n; i += 2)
{
if(!a[i])
{
nr++;
for(unsigned long long j = i + i + i; j <= n; j += i)
a[j] = 1;
}
}
}
int main()
{
f>>n;
eratosthenes();
g<<nr;
g.close();
return 0;
}