[ACM]Uva839-Not So Mobile(树状天平)
在输入过程中同时进行数据处理,代码简洁,效率较高
#include<iostream>
#include<cstdio>
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"<<endl; else cout<<"NO"<<endl;
if(T) cout<<endl;
}
return 0;
}
[ACM]Uva839-Not So Mobile(树状天平)的更多相关文章
- UVa839 Not so Mobile
我的解法: 建树,递归判断 #include<cstdio> #include<cstring> #include<iostream> #include< ...
- UVa 839 -- Not so Mobile(树的递归输入)
UVa 839 Not so Mobile(树的递归输入) 判断一个树状天平是否平衡,每个测试样例每行4个数 wl,dl,wr,dr,当wl*dl=wr*dr时,视为这个天平平衡,当wl或wr等于0是 ...
- HDU 5458 Stability(双连通分量+LCA+并查集+树状数组)(2015 ACM/ICPC Asia Regional Shenyang Online)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5458 Problem Description Given an undirected connecte ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
- POJ 1195 Mobile phones(二维树状数组)
Mobile phones Time Limit: 5000MS Mem ...
- 【POJ1195】【二维树状数组】Mobile phones
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- (简单) POJ 1195 Mobile phones,二维树状数组。
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- 2018牛客网暑假ACM多校训练赛(第五场)H subseq 树状数组
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round5-H.html 题目传送门 - https://www.no ...
- 2018牛客网暑假ACM多校训练赛(第五场)F take 树状数组,期望
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round5-F.html 题目传送门 - https://www.no ...
- 2018牛客网暑期ACM多校训练营(第五场) F - take - [数学期望][树状数组]
题目链接:https://www.nowcoder.com/acm/contest/143/F 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K ...
随机推荐
- git log 查看分支图
操作: 在git config文件里面设置别名. git config --global alias.lg "log --graph --all --pretty=format:'%Cred ...
- openSUSE Tumbleweed 安装原生微信
优麒麟网站上有提供下载. 之前用 Ubuntu的时候,直接安装就可以使用. ...
- 关于js数组方法filter()
1. filter() 都是数组方法,这个方法和forEach()的方法的区别又是什么呢? 2. 先说结论 filter() 和 forEach() 都是遍历数组的方法,甚至它们匿名函数的形参都是一样 ...
- C#使用JSON相关
一.Json字符串转换为Dictionary /// <summary> /// JSON字符串转为 Dictionary /// </summary> /// <typ ...
- Shell写脚本关于ssh执行jar包,需要刷新JDK路径的问题
比如脚本中下面这一段 ssh $i "java -jar /applog/$PROJECT/$APPNAME --server.port=$SERVER_PORT >/dev/null ...
- C语言II—作业03
1.作业头 这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/SE2020-3 这个作业要求在哪里 https://edu.cnblogs.com/cam ...
- input类型为number仍可以输入e,+,-解决方法
<input type="number" onKeypress="return(/[\d\.]/.test(String.fromCharCode(event.ke ...
- Lua元表应用举例:配置表格转为Lua配置表
把配置表格.xlsx数据转为Lua配置表,其实就是把表格数据用Lua写一遍,这里的实现重点就是setmetatable设置元表. 以下以表格student_info.xlsx举例,展示对应Lua配置表 ...
- 2020/03/25 CSS相关知识点
2020-03-25 16:35:03 又是一个风和日丽的下午!今天的内容比较多 真是令人头大 ,手速又慢所以缺的可能比较多,而且这东西还是多靠实践为好. 文件下载地址: https://share. ...
- Angular Material TreeTable Component 使用教程
一. 安装 npm i ng-material-treetable --save npm i @angular/material @angular/cdk @angular/animations -- ...