Pagini recente » Istoria paginii runda/bac-calinush/clasament | Cod sursa (job #792266) | Cod sursa (job #3216165) | Cod sursa (job #758291) | Cod sursa (job #664428)
Cod sursa(job #664428)
// http://infoarena.ro/problema/ciur
#include <fstream>
using namespace std;
const int MAXSIZE = 2000001;
ifstream in("ciur.in");
ofstream out("ciur.out");
int length;
bool numbers[MAXSIZE];
void eratosthenes();
int main()
{
in >> length;
in.close();
eratosthenes();
int count = 0;
for(int i=3;i<=length;i+=2)
if(!numbers[i])
count++;
out << ++count << "\n";
out.close();
return (0);
}
void eratosthenes()
{
int stop = length / 2;
for(int i=3;i<=stop;i+=2)
for(int k=i+i;k<=length;k=k+(i << 1))
numbers[k] = true;
}