fork download
  1. #include <stdio.h>
  2. main() {
  3. int n;
  4. int x;
  5. scanf("%d",&n);
  6. while (n>0) {
  7. n=n-1;
  8. scanf("%d",&x);
  9. if (x==1) {
  10. printf("2\n");
  11. } else if (x==2) {
  12. printf ("3\n");
  13. } else if (x==3) {
  14. printf ("5\n");
  15. } else if (x==4) {
  16. printf("7\n");
  17. } else if (x==5) {
  18. printf("11\n");
  19. } else if (x==6) {
  20. printf("13\n");
  21. } else if (x==7) {
  22. printf("17\n");
  23. } else if (x==8) {
  24. printf("19\n");
  25. } else if (x==9) {
  26. printf("23\n");
  27. } else {
  28. int h = 24;
  29. int s = 9;
  30. while (h<542) {
  31. h=h+1;
  32. if ( (h%2)!=0 && (h%3)!=0 && (h%5)!=0 && (h%7)!=0 && (h%11)!=0 && (h%13)!=0 && (h%17)!=0 && (h%19)!=0 && (h%23)!=0 ) {
  33. s=s+1;
  34. if (x==s) {
  35. printf("%d\n",h);
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 0s 2160KB
stdin
3
4
10
20

stdout
7
29
71