Mai intai trebuie sa te autentifici.
Cod sursa(job #2456506)
Utilizator | Data | 14 septembrie 2019 15:13:05 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
long long unsigned n, i, j, c; c = 1;
vector <bool>A(n + 3, 0);
fin >> n;
for(i = 3; i <= n; i += 2)
{
if(A[i] == 0)
{
++c;
for(j = 2; j <= n/i; ++j)
A[i * j] = 1;
}
}
fout << c;
return 0;
}