UVA839NotSoMobile

来源:互联网 发布:罗马复兴兵种数据 编辑:程序博客网 时间:2024/06/05 17:52
//UVA839NotSoMobile#include<cstdio>#include<iostream>using namespace std;bool solve(int &W) {int W1, D1, W2, D2;scanf("%d%d%d%d", &W1, &D1, &W2, &D2);bool b1 = true, b2 = true;if(!W1) b1 = solve(W1);if(!W2) b2 = solve(W2);W = W1 + W2;return b1 && b2 && (W1 * D1 == W2 * D2);}int main() {int kase = 0;int W;scanf("%d", &kase);while(kase--){//printf("////");    puts(solve(W) ? "YES" : "NO");    if(kase) printf("\n");    }return 0;}

原创粉丝点击