asgarlikanan

https://www.e-olymp.com/az/problems/830

Aug 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 0.50 KB | None | 0 0
  1. /*
  2.     Author: Kanan Asgarli
  3.     https://www.e-olymp.com/az/problems/830
  4. */
  5. #include <iostream>
  6. #include <cmath>
  7. #define MAX 300000
  8. using namespace std;
  9. int p[MAX+1], f, m, n;
  10. void primes(){
  11.     for(int i = 2; i <= (int)sqrt(MAX); i++)
  12.         if(p[i] == 0)
  13.             for(int j = i*i; j <= MAX; j += i)
  14.                 p[j] = 1;
  15.     }
  16. int main()
  17. {
  18.     primes();
  19.     cin>>m>>n;
  20.     for(int i = m; i <= n; i++ )
  21.         if(p[i] == 0){
  22.             f = 1;
  23.             cout<<i<<endl; 
  24.         }
  25.     if(f == 0)
  26.         cout<<"Absent"<<endl;
  27.    
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment