Cod sursa(job #3215567)
| Utilizator | Data | 15 martie 2024 10:09:08 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
//CIURUL LUI Eratosthenes ------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
const int nmax = 2e6 + 2;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, total;
bool ciur[nmax];
int main()
{
fin>>n;
for(int i=2;i<=n;i++){
if(ciur[i] == 0){
total ++;
for(int j=i;j<=n;j+=i){
ciur[j] = 1;
}
}
}
fout<<total;
}
