Files
contests/2022/republic/d0/problem04/problem04.cpp
2022-06-01 20:14:50 +03:00

39 lines
519 B
C++

#include <iostream>
#include <list>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int start, end;
cin >> start >> end;
int notPrimes[end + 5] = {0};
bool foundPrime = false;
for (int i = 2; i <= end; i++) {
if (notPrimes[i] != 0) {
continue;
}
if (start <= i && i <= end) {
cout << i << " ";
foundPrime = true;
}
for (int j = i; j <= end; j += i) {
notPrimes[j] = i;
}
}
if (!foundPrime) {
cout << "Absent" << endl;
}
return 0;
}