fork download
  1. program horsey;
  2. var T, test:integer;
  3. N,M,H,W : int64;
  4. ans : string[4];
  5. Procedure scambia (var a,b: Int64);
  6. var x:Int64;
  7. begin
  8. x:=a;
  9. a:=b;
  10. b:=x;
  11. end;
  12.  
  13. function MCD (a ,b :int64): int64;
  14. VAR
  15. resto: integer;
  16.  
  17. BEGIN
  18. REPEAT
  19. resto := a MOD b;
  20. a := b;
  21. b := resto
  22. UNTIL resto = 0;
  23. MCD:=a;
  24. END;
  25.  
  26. begin
  27. readln(T);
  28. for test:=1 to T do
  29. begin
  30. readln(N,M,H,W);
  31. if N<M then scambia(N,M);
  32. if H<W then scambia (H,W);
  33.  
  34. if ((H+W) mod 2 =0) or (MCD(H,W)<>1) then ans:='NO'
  35. else if (M<H+W) or (N<(2*H)) then ans:='NO'
  36. else ans:='YES';
  37. writeln(ans);
  38. end;
  39. end.
Success #stdin #stdout 0s 5300KB
stdin
2
2 2 5 7
8 8 1 2
stdout
NO
YES