Saleh127

uva 686.cpp

Jun 9th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int mark[32768],prime[32768],x=0;
  4. void sieve()
  5. {
  6. int i, j;
  7. for(i = 2; i < 32768; i++)
  8. {
  9. if(mark[i] == 0)
  10. {
  11. prime[x++] = i;
  12. for(j = 2; i*j < 32768; j++)
  13. {
  14. mark[i*j] = 1;
  15. }
  16. }
  17. }
  18. }
  19. int main()
  20. {
  21. sieve();
  22. int a;
  23. while(scanf("%d",&a)==1 && a)
  24. {
  25. int i, c, d, ans = 0;
  26. for(i = 0; prime[i] < a; i++)
  27. {
  28. c = prime[i];
  29. d = a-c;
  30. if(c > d)
  31. {
  32. break;
  33. }
  34. if(mark[d] == 0)
  35. ans++;
  36. }
  37. printf("%d\n", ans);
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment