fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6. short ilebadan;
  7. cin >> ilebadan;
  8.  
  9. short *badanie = new short[ilebadan];
  10.  
  11. int *odilu = new int[ilebadan];
  12. int *ile = new int[ilebadan];
  13.  
  14. for (int x = 0; x < ilebadan; x += 1)
  15. {
  16. cin >> odilu[x] >> ile[x];
  17. }
  18.  
  19. for (int x = 0; x < ilebadan; x += 1)
  20. {
  21. bool *booltab = new bool[ile[x]];
  22.  
  23. for (int i = 0; i < ile[x]; i += 1)
  24. {
  25. booltab[i] = true;
  26. }
  27.  
  28.  
  29. for (int i = 2; i <= (sqrt(ile[x])); i += 1)
  30. {
  31.  
  32.  
  33. if (booltab[i - 2] == true)
  34. {
  35.  
  36. int j = 0;
  37. for (int it = 0; j <= (ile[x] + 1); it += 1)
  38. {
  39. j = ((i*i) + (it*i));
  40.  
  41. booltab[j - 2] = false;
  42. }
  43. }
  44. }
  45.  
  46. for (int i = 0; i < ile[x]; i += 1)
  47. {
  48. if (booltab[i] == true && (i+2) >= odilu[x] && (i+2) <= ile[x]) cout << (i + 2) << endl;
  49. }
  50. cout << endl;
  51. }
  52. delete[] badanie;
  53. delete[] odilu;
  54. delete[] ile;
  55. }
Success #stdin #stdout 0s 3472KB
stdin
1
120 320
stdout
127
131
137
139
149
151
157
163
167
173
179
181
191
193
197
199
211
223
227
229
233
239
241
251
257
263
269
271
277
281
283
293
307
311
313
317