fork(2) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int t,flag=1;
  6. long long int x,y;
  7. scanf("%d",&t);
  8. while(t--){
  9. scanf("%lld %lld",&x,&y);
  10. flag=1;
  11. if(x==0 && y==0){flag=1;}
  12. else if(x==0){
  13. if(y%2!=0){flag=0;}
  14. }
  15. else if(y==0){
  16. if(x<0 && x%2!=0){flag=0;}
  17. else if(x>0 && x%2==0){flag=0;}
  18.  
  19. }
  20.  
  21. else if(x>0){
  22. if(x%2==0){
  23. if(y%2!=0){flag=0;}
  24. }
  25. else if(x%2!=0){
  26. if(y%2!=0){
  27. if(y>0 && y>x){
  28. flag=0;
  29. }
  30. else if(y<0){
  31. y=y*(-1);
  32. if(x<=y){flag=0;}
  33. }
  34. }
  35. }
  36. }
  37. else if(x<0){
  38. x=x*(-1);
  39. if(x%2==0){
  40. if(y<0 && y%2!=0){
  41. y=y*(-1);
  42. if(y>x)flag=0;}
  43. }
  44. else if(x%2!=0){
  45. if(y%2!=0){flag=0;}
  46. else if(y%2==0 && y>0 && y<x){flag=0;}
  47. else if(y%2==0 && y<0){
  48. y=y*(-1);
  49. if(y<x){flag=0;}
  50. }
  51. }
  52. }
  53. if(flag==1){printf("YES\n");}
  54. else if(flag==0){printf("NO\n");}
  55.  
  56.  
  57. }//wh
  58.  
  59.  
  60. return 0;
  61. }
  62.  
Success #stdin #stdout 0s 2296KB
stdin
6
3 0
-2 0
-2 2
-1 0
-3 5
-4 0
stdout
YES
YES
YES
NO
NO
YES