您的位置:首页 > 其它

Uva 839 Not so Mobile

2014-07-18 10:56 387 查看
Not so Mobile
Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small babies.

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
bool solve(int& W)
{
int W1,D1,W2,D2;
bool b1=true,b2=true;
cin>>W1>>D1>>W2>>D2;
if(!W1)b1=solve(W1);
if(!W2)b2=solve(W2);
W=W1+W2;
return b1 && b2 && (W1*D1==W2*D2);
}
int main()
{
int T,W;
cin>>T;
while(T--)
{
if(solve(W))
cout<<"YES\n";
else
cout<<"NO\n";
if(T)
printf("\N");
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: