// uva 839 - Not so Mobile
// 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=780
// wr或wl为0的的话表示有子树,判断是否平衡, wl, dl, wr, dr 分别表示左端的重量,左端到平衡点的长度,右端的重量,右端到平衡点的长度
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int cnt_case;
bool ok;
void Init();
int Judge();
void Print();
int main(){
cin >> cnt_case;
while(cnt_case--){
Init();
Judge();
Print();
}
return 0;
}
void Init(){
ok = true;
}
int Judge(){
int wl, wr, dl, dr;
scanf("%d %d %d %d", &wl, &dl, &wr, &dr);
if(wl == 0)
wl = Judge();
if(wr == 0)
wr = Judge();
if(wl * dl != wr * dr)
ok = false;
return wl + wr;
}
void Print(){
if(ok)
cout << "YES" << endl;
else
cout << "NO" << endl;
if(cnt_case)
cout << endl;
}
uva 839 - Not so Mobile
最新推荐文章于 2021-09-06 10:14:39 发布
