fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7. long long int t,n,m;
  8. scanf("%lld",&t);
  9. while(t--)
  10. {
  11. scanf("%lld%lld",&n,&m);
  12. long long int a[m];
  13. for(int i=0;i<=m;i++)
  14. a[i]=1;
  15. a[0]=0;
  16. a[1]=0;
  17. for(int k=2;k<=sqrt(m);k++)
  18. {
  19. if(a[k]==1)
  20. {
  21. for(int l=2;k*l<=m;l++)
  22. {
  23. a[k*l]=0;
  24. }
  25. }
  26. }
  27. for(long long int c=n;c<=m;c++)
  28. {
  29. if(a[c]==1)
  30. {
  31. printf("%lld\n",c);
  32. }
  33. }
  34. printf("\n");
  35.  
  36. }
  37. }
Success #stdin #stdout 0s 2688KB
stdin
2
1 10
3 5
stdout
2
3
5
7

3
5