Not so Mobile (针对递归输入的函数)
2015-07-22 14:45
405 查看
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> using namespace std; bool solve(int &W) { int W1,W2,D1,D2; cin>>W1>>D1>>W2>>D2; bool b1=true,b2=true; if(W1==0) b1=solve(W1); if(W2==0) 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) cout<<"\n"; } return 0; } View Code |
相关文章推荐
- spring验证事务的代码,用到了mockito
- Objective-C中应用断言_assert()
- 五种常见的 PHP 设计模式
- Android Studio使用技巧系列教程(三)
- ARMCC和GCC编译ARM代码的软浮点和硬浮点问题
- &>/dev/null
- 使用class_attribute 生sys文件系统下生成调试文件,方便使用adb调试
- spring mongodb — upsert
- jquery 幻灯片 左右滚动
- IE8判断
- 【0722】T1 中位数
- 设计模式:模版模式(Template Pattern)
- 强大的火狐插件(转)
- hdu 2888 Check Corners (二维rmq模版)
- POJ 1068:Parencodings
- 开源音视频 库
- Expose ADF BC as RESTful Web Service
- POJ 1068:Parencodings
- 十进制有限小数如何以二进制保存而不会变成无限小数
- jemalloc和内存管里