- #include<iostream>
- using namespace std;
- //通过引用返回左右重物之和
- bool solve(int& W){
- int Wl,Dl,Wr,Dr;
- cin>>Wl>>Dl>>Wr>>Dr;
- bool b1=true,b2=true;
- if(!Wl)b1=solve(Wl);
- if(!Wr)b2=solve(Wr);
- W=Wl+Wr;
- return b1&& b2&&(Wl*Dl==Wr*Dr);
- }
- int main(){
- int T;
- cin>>T;
- while(T--){
- int w;
- if(solve(w))cout<<"YES"<<endl;
- else cout<<"NO"<<endl;
- if(T)cout<<endl;
- }
- return 0;
- }
07-17
07-17
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交