fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3.  
  4. int a[100000], s[131072];
  5.  
  6. int main(void) {
  7. int n, x, h, p, r;
  8. p = 0, h = 0;
  9. while (1) {
  10. if (!scanf("%d", &x)) break;
  11. else if (x & 1 << 31 || x >> 17) break;
  12. if (x > h) h = x;
  13. a[p] = x;
  14. p++;
  15. }
  16. for (int i = 2; i <= h; i++) {
  17. for (int j = i << 1; j <= h; j += i) s[j]++;
  18. }
  19. while (p --> 0) {
  20. switch (a[p]) {
  21. case 0:
  22. case 2:
  23. case 4:
  24. printf("%d ", a[p]);
  25. break;
  26. default:
  27. r = 0;
  28. for (int i = 3; i << 1 <= a[p]; i++) {
  29. if (!(s[i] | s[a[p] - i])) {
  30. r = 1;
  31. break;
  32. }
  33. }
  34. if (r) printf("%d ", a[p]);
  35. }
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5468KB
stdin
1 2 3 4 5 6 7 8 9 10 12 14 22 33 45 60 90 120 225 337 433 567 777 1000
1234 2345 3456 7654 10000 100000 123456 65536 asdf
stdout
65536 123456 100000 10000 7654 3456 1234 1000 120 90 60 22 14 12 10 8 6 4 2