uva 839 Not so Mobile
来源:互联网 发布:大连 育知同创 郑爽 编辑:程序博客网 时间:2024/05/22 14:12
题目:Not so Mobile
题意:有一串吊在一起的杠杆,问是否能平衡。按dfs序输入杠杆。
思路:dfs。
代码:
#include<cstdio>#include<iostream>#include<string>#include<cstring>#include<vector>#include<set>#include<map>#include<algorithm>#include<cmath>#include<queue>#include<stack>#include<deque>using namespace std;int dfs(){int w1,d1,w2,d2;scanf("%d%d%d%d",&w1,&d1,&w2,&d2);int l=w1,r=w2;if(w1==0) l=dfs();if(w2==0) r=dfs();if(l*d1==r*d2&&r!=-1&&l!=-1) return l+r;return -1;}int main() {int T;scanf("%d",&T);while(T--){if(dfs()==-1) printf("NO\n");else printf("YES\n");if(T) printf("\n");}return 0;}
阅读全文
2 0
- uva 839 - Not so Mobile
- uva 839 Not so Mobile
- uva 839 - Not so Mobile
- UVa 839 - Not so Mobile
- UVa 839 - Not so Mobile
- uva-839 Not so Mobile
- uva 839 - Not so Mobile
- UVA 839 Not so Mobile
- uva 839 Not so Mobile
- Not so Mobile UVA 839
- uva 839 - Not so Mobile
- uva 839 Not so Mobile
- UVa 839 - Not so Mobile
- UVA - 839 Not so Mobile
- UVA 839 Not so Mobile
- UVA - 839 Not so Mobile
- UVA 839 - Not so Mobile
- UVA - 839 Not so Mobile
- 无刷直流电机
- http://blog.csdn.net/bolu1234/article/details/51867099
- 极大连通子图 + 极小连通子图 + 连通分量
- linux系统常用配置讲解
- oracle怎样修改表名、列名、字段类型、添加表列、删除表列
- uva 839 Not so Mobile
- 主函数调用其他源文件定义的全局变量偶尔出错
- 【矩阵快速幂】HDU_1005_Number Sequence
- There is no Action mapped for namespace[/] and action name [] associated with context path.
- js系列教程4-函数、函数参数全解
- CNN(卷积神经网络)概述
- 构建前端开发框架
- QT正则表达式
- Matlab读取的图像的数据排列