#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#define Status int
#define OK 1
#define ERROR 0
using namespace std;
Status Judge(int& w)// 输入四个数 若子树重量为0 则继续执行输入函数 并引用改变其总重量w
{
int w1 = 0, d1 = 0, w2 = 0, d2 = 0;
cin >> w1 >> d1 >> w2 >> d2;
int j1 = OK, j2 = OK;// 判断子树平衡
if (!w1)j1 = Judge(w1);
if (!w2)j2 = Judge(w2);
w = w1 + w2;
return j1&&j2&&w1*d1 == w2*d2;
}
int main()
{
int T = 0,w=0;
cin >> T;
while (T--)
{
if (Judge(w))cout << "YES"; else cout << "NO";
cout << endl;
if (T)cout << endl;
}
}
UVA-839 Not so Mobile
最新推荐文章于 2024-08-15 05:02:54 发布