Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user