Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool a[2000]={true};
- int main()
- {
- int n,i,j,k,l,c,d,e,f;
- a[1]=false;
- a[0]=true;
- for(i=2;i<=2000;i++)
- {
- if(a[i]==false)
- {
- for(j=i*i;j<=2000;j+=i)
- {
- a[j]=true;
- }
- }
- }
- while(cin>>n>>c)
- {
- d=0;
- for(i=1;i<=n;i++)
- {
- if(a[i]==false) d++;
- }
- e=2*c;
- if(d%2) e--;
- f=(d-e)/2;
- l=0;
- cout<<n<<" "<<c<<":";
- for(i=1;i<=n;i++)
- {
- if(a[i]==false)
- {
- l++;
- if(l>(e+f)) break;
- if(l>f) cout<<" "<<i;
- }
- }
- cout<<endl<<endl;
- }
- }
Add Comment
Please, Sign In to add comment