Pagini recente » Cod sursa (job #2195040) | Cod sursa (job #1651672) | Cod sursa (job #1517029) | Cod sursa (job #2201801) | Cod sursa (job #2034969)
// ConsoleApplication22.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int n,cnt;
bool mark[2000001];
void verif()
{
int i,j;
for (i = 2; i <= sqrt(n); i++)
{
for (j = i; j*i <= n; j++)
{
mark[i*j] = 1;
}
if (mark[i] == 0)
cnt++;
}
}
int main()
{
int i;
f >> n;
verif();
for (i = sqrt(n)+1; i <= n; i++)
if (mark[i] == 0)
cnt++;
g << cnt ;
return 0;
}