fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. int x,y,c;
  10. cin>>x>>y>>c;
  11. int a=abs(y-x);
  12. int b=c*2;
  13. if(x<=y)
  14. {
  15. if(a%b==0)
  16. cout<<"YES\n";
  17. else
  18. cout<<"NO\n";
  19. }
  20. else if(x>y){
  21. if(a%b==0)
  22. cout<<"YES\n";
  23. else
  24. cout<<"NO\n";
  25. }
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 5464KB
stdin
4
5 7 1
3 4 2
4 4 6
2 5 3
stdout
YES
NO
YES
NO