Advertisement
Graf_Rav

Untitled

Jan 10th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. const int N=1000000;
  7.  
  8. int main(){
  9.     vector<bool> arr(N+1, true);//решето
  10.     int a=2;
  11.     while(1){
  12.         int b=2;
  13.         while(a*b<=N){
  14.             arr[a*b]=false;
  15.             b++;
  16.         }
  17.         if(b==2){
  18.             break;
  19.         }
  20.         a++;
  21.     }
  22.     int n,m;
  23.     cin>>m>>n;
  24.     bool fl=true;
  25.     for(int i=m;i<=n;i++){
  26.         if(arr[i]){
  27.             fl=false;
  28.             cout<<i<<'\n';
  29.         }
  30.     }
  31.     if(fl){
  32.         cout<<"Absent";
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement