Cod sursa(job #558602)
| Utilizator | Data | 17 martie 2011 13:01:32 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include<fstream>
using namespace std;
short x[2000000];
int main()
{
int n,i,j,c=0;;
ifstream In("ciur.in");
In>>n;
In.close();
for(i=2;i<n;i++)
{
if(!x[i])
{
for(j=2*i;j<=n;j+=i)
x[j]=1;
c++;
}
}
ofstream Out("ciur.out");
Out<<c;
Out.close();
return 0;
}
