Cod sursa(job #3343909)
| Utilizator | Data | 28 februarie 2026 18:17:13 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
/// patratele
#include <bits/stdc++.h>
using namespace std;
#define Nmax 2000005
#define pb push_back
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int i,n,j,s;
bool v[Nmax];
int main()
{
// ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fin>>n;
for(i=2;i<=n;i++)
{
if(v[i]==0)
{
s++;
for(j=2*i;j<=n;j+=i)
v[j]=1;
}
}
fout<<s;
return 0;
}
