Cod sursa(job #2254079)
Utilizator | Data | 4 octombrie 2018 19:21:18 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream in("prim.in");
ofstream out("prim.out");
const int VM = 1500000;
bool c[VM];
int main()
{
int k, n, z=0;
in>>k;
for(int i=2;i*i<VM;i++){
if(!c[i]){
for(int j=i*i;j<VM;j+=i){
c[j]=true;
}
}
}
int x = 2;
while (k >= 0)
{
if (!c[x]) {
z++;
}
x++;
k--;
}
x--;
out<<z-1;
return 0;
}