UVA 839(p157)----Not so Mobile

#include<bits/stdc++.h>
using namespace std;
int flag;
int solve()
{
    int w1,d1,w2,d2;
    scanf("%d%d%d%d",&w1,&d1,&w2,&d2);
    if(!w1) w1=solve();
    if(!w2) w2=solve();
    if(w1*d1!=w2*d2) flag=0;
    return w1+w2;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        flag=1;
        solve();
        if(flag) printf("YES\n");
        else printf("NO\n");
        if(t) printf("\n");
    }
    return 0;
}
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=780

你可能感兴趣的:(UVA 839(p157)----Not so Mobile)