Pagini recente » Cod sursa (job #2313589) | Cod sursa (job #2173218) | Cod sursa (job #1333876) | Cod sursa (job #2677646) | Cod sursa (job #2237602)
#include <fstream>
using namespace std;
int i,j,x,cnt;
long long int n;
long long int l = 2000000;
fstream f ("ciur.in");
ofstream g ("ciur.out");
int main() {
f >> n;
if(n >= 2 && n <= l ) {
bool nr[n]= {false};
for(i = 2;i<=n*0.5;i++) {
if (!nr[i]) {
for (j = i*i; j<=n;j+=i) {
nr[j] = 1;
}
}
}
for (x = 1;x<=n;x++) {
if (nr[x] == 0) {
cnt++;
}
}
g << cnt - 1;
}
return 0;
}