Cod sursa(job #2377641)
Utilizator | Data | 10 martie 2019 19:20:13 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 80 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
int n,i,j;
f>>n;
char A[n+1]={0};
int c=0;
int st;
for(i=2;i<n+1;i++){
if(A[i]==0){
j=i;
st=j;
c++;
while(j<n+1){
if(j%i==0)
A[j]=1;
j+=st;
}
}
}
g<<c;
g.close();
f.close();
return 0;
}