fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void solve(){
  5. long long r,c,m,k,j;
  6. cin>>r>>c>>m>>k>>j;
  7. if(r*c != (m+k+j)){
  8. cout<<"No"<<endl;
  9. }else{
  10. bool isPoss = false;
  11. if(m%r==0){
  12. long long lf = c - m/r;
  13. if(lf>0 && ((j%lf==0 && k%lf==0) || (j%r==0 && k%r==0))){
  14. isPoss = true;
  15. }
  16. }
  17. if(k%r==0){
  18. long long lf = c - k/r;
  19. if(lf>0 && ((j%lf==0 && m%lf==0) || (j%r==0 && m%r==0))){
  20. isPoss = true;
  21. }
  22. }
  23. if(j%r==0){
  24. long long lf = c - j/r;
  25. if(lf>0 && ((m%lf==0 && k%lf==0) || (m%r==0 && k%r==0))){
  26. isPoss = true;
  27. }
  28. }
  29. if(m%c==0){
  30. long long lf = r - m/c;
  31. if(lf>0 && ((j%lf==0 && k%lf==0) || (j%c==0 && k%c==0))){
  32. isPoss = true;
  33. }
  34. }
  35. if(k%c==0){
  36. long long lf = r - k/c;
  37. if(lf>0 && ((j%lf==0 && m%lf==0) || (j%c==0 && m%c==0))){
  38. isPoss = true;
  39. }
  40. }
  41. if(j%c==0){
  42. long long lf = r - j/c;
  43. if(lf>0 && ((m%lf==0 && k%lf==0) || (m%c==0 && k%c==0))){
  44. isPoss = true;
  45. }
  46. }
  47. if(isPoss){
  48. cout<<"Yes"<<endl;
  49. }else{
  50. cout<<"No"<<endl;
  51. }
  52. }
  53. }
  54.  
  55. int main() {
  56. int t;
  57. cin>>t;
  58. while(t--) solve();
  59. return 0;
  60. }
Success #stdin #stdout 0s 3464KB
stdin
4
4 5 10 4 6
4 5 6 10 4
4 5 4 6 10
2 2 2 2 2
stdout
Yes
Yes
Yes
No