Cod sursa(job #3295976)
| Utilizator | Data | 10 mai 2025 12:19:18 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n;
int vf[105];
int main()
{
fin >> n;
for(int i = 2; i * i <= n; i ++)
{
if(vf[i] == 0)
for(int j = i * i; j <= n; j += i)
{
vf[j] = 1;
}
}
int k = 0;
for(int i = 2; i <= n; i ++)
{
if(vf[i] == 0)
k++;
}
fout << k;
return 0;
}
