Cod sursa(job #555670)

Utilizator valentin.harsanValentin Harsan valentin.harsan Data 15 martie 2011 18:05:55
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.3 kb
#include<iostream>
#include<fstream>
using namespace std;
ifstream aa("ciur.in");
ofstream ss("ciur.out");
int main() {
int i,j,n,u;
bool c[2000001];
for (i=2;i*i<n;++i) {
if (!c[i]) {
for (j=i*i;j<=n;j+=i)
c[j]=true;
}
}
for (i=2;i<=n;++i) {
if (!c[i]) {
++u;
aa >> n;
ss << u;
return 0;
}