Cod sursa(job #1477455)
| Utilizator | Data | 26 august 2015 12:41:35 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#define lm 2000001
#define pb push_back
using namespace std;
int n,res=0;
bool l[lm];
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
for (int i=2; i<=n; i++)
if(!l[i])
{
res++;
for (int j=i+i; j<=n; j+=i)
l[j]=true;
}
g<<res;
return 0;
}
