UVa839

时间:2022-03-18 17:25:28

这个引用好精髓。

 #include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
const double Pi=3.14159265358979323846;
typedef long long ll;
const int MAXN=+;
const int dx[]={,,,,-};
const int dy[]={,-,,,};
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll mod=1e9+; bool solve(int &w)
{
int w1,w2,d1,d2;
cin>>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&&(d1*w1==d2*w2));
} int main()
{
int t;cin>>t;
while(t--)
{
int w;
if(solve(w)) cout <<"YES\n";
else cout <<"NO\n";
if(t) cout<<"\n";
}
return ;
}

相关文章