fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  5. #define pb push_back
  6. #define alls(x) x.begin(), x.end()
  7. #define sz(x) (int)(x.size())
  8. #define forn(i,n) for(int i=0; i<int(n); i++)
  9. #define rep(i,n) for(int i=1; i<=int(n); i++)
  10. #define inc(i,l,r,d) for(int i=l; i<=r; i+=d)
  11. #define dec(i,r,l,d) for(int i=r; i>=l; i-=d)
  12. #define dbg(x) cerr << #x << " = " << x << endl;
  13. #define nl cout << "\n";
  14. #define sp cout << " ";
  15. #define pii pair<int, int>
  16. #define pll pair<ll, ll>
  17. #define vi vector<int>
  18. const ll inf = 1e16;
  19. const ll mod = 998244353;
  20. const ll mod1 = 1e9 + 87;
  21. const ll mod2 = 127397154761;
  22. ll gcd(ll a, ll b) {if (b == 0) return a; return gcd(b, a % b);}
  23. ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
  24. ll sum(ll a, ll b) {a += b; if (a >= mod) a -= mod; return a;}
  25. ll sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
  26. ll mul(ll a, ll b) {return a * b % mod;}
  27.  
  28.  
  29. //========================================
  30. //Author: Muntazir Ali
  31. //Institution: IIIT JABALPUR
  32. //========================================
  33.  
  34. void ali(){
  35. ll w,h,a,b,x1,y1,x2,y2;
  36. cin >> w >> h >> a >> b >> x1 >> y1 >> x2 >> y2;
  37. bool hp = false;
  38. if((y1-y2)%b==0){
  39. if(y1==y2){
  40. if((x1-x2)%a==0) hp = true;
  41. }
  42. else hp = true;
  43. }
  44. bool vp = false;
  45. if((x1-x2)%a==0){
  46. if(x1==x2){
  47. if((y1-y2)%b==0) vp = true;
  48. }
  49. else vp = true;
  50. }
  51. if(hp || vp) cout << "Yes" << endl;
  52. else cout << "No" << endl;
  53. }
  54. int main(){
  55. fast
  56. int t;
  57. cin >> t;
  58. while(t--){
  59. ali();
  60. }
  61. return 0;
  62. }
  63.  
  64.  
  65.  
Success #stdin #stdout 0.01s 5288KB
stdin
7
6 5 2 3
-1 -2 5 4
4 4 2 2
0 0 3 1
10 9 3 2
0 0 4 3
10 9 3 2
0 0 6 3
5 5 2 2
-1 -1 4 -1
5 5 2 2
-1 -1 2 3
7 8 2 4
0 0 0 5
stdout
Yes
No
No
Yes
No
Yes
No