Cod sursa(job #2764826)
Utilizator | Data | 22 iulie 2021 19:41:28 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f ("ciur.in");
ofstream g ("ciur.out");
bool a[2000001];
vector <int> V;
int main()
{
int n;
f >> n;
for (int i = 2; i <= n; i++)
{
if (a[i] == 0)
{
V.push_back(i);
for (int j = 2*i; j <= n; j += i)
{
a[j] = 1;
}
}
}
g << V.size();
}