Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a, b;
- bool was[1000500];
- int main() {
- was[0] = was[1] = true;
- cin >> a >> b;
- for (int i = 2; i <= 1000000; i++) {
- if (was[i] != true) {
- if (i * 1ll * i <= 1000000) {
- for (int j = i * i; j <= b; j += i)
- was[j] = true;
- }
- }
- }
- int cnt = 0;
- for(int i = a; i <= b; i++){
- if(was[i] == 0){
- cout << i << endl;
- cnt++;
- }
- }
- if(cnt == 0){
- cout << "Absent";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment