Cod sursa(job #2639420)
Utilizator | Data | 2 august 2020 00:12:02 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int n;
vector<int> v;
int main()
{
f >> n;
for(int i = 2; i <= n; i++) {
bool ok = 1;
for(unsigned int j = 0; j < v.size(); j++) {
if(i % v[j] == 0) {
ok = 0;
break;
}
}
if(ok) {
v.push_back(i);
}
}
g << v.size();
return 0;
}