fork(1) download
  1. #include<iostream>
  2.  
  3. #include<math.h>
  4. using namespace std;
  5. int main()
  6. {
  7. int a,b,c,i,j,k,d,u;
  8. float g;
  9.  
  10. cin>>d;
  11. for(k=0;k<d;k++)
  12. {
  13. cin>>u;
  14. cin>>a;
  15. g=a;
  16. bool m[a];
  17. for(i=2;i<=a;i++)
  18. {
  19. m[i]=true;
  20. }float z;int q;
  21. z=sqrt(g);
  22.  
  23.  
  24.  
  25. for(i=2;i<=z;i++)
  26. {
  27. if(m[i]==true)
  28. {
  29. for(j=0;;j++)
  30. {
  31. q=(i*i)+(j*i);
  32. if(q<=a)
  33. m[q]=false;
  34. else
  35. break;
  36. }
  37. }
  38. }
  39. for(i=2;i<=a;i++)
  40. {
  41. if((m[i]==true)&&(i>=u))
  42. cout<<i<<"\n";
  43. }
  44. cout<<"\n";
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
Standard output is empty