UVA - 571 - Jugs (数论 - 经典倒水问题)
来源:互联网 发布:it人才培训机构 编辑:程序博客网 时间:2024/05/29 00:34
题目传送:UVA - 571
思路:A为空时就加满,不空就倒给B,B满了后就全倒掉,直到B的容量为n(参考)
AC代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <deque>#include <cctype>#define LL long long#define INF 0x7fffffffusing namespace std;int main() {int a, b, ca, cb, n;while(scanf("%d %d %d", &ca, &cb, &n) != EOF) {a = 0, b = 0;while(1) {if(b == n) {printf("success\n");break;}else if(b == cb) {printf("empty B\n");b = 0;}else if(a == 0) {printf("fill A\n");a = ca;}else if(a != 0) {printf("pour A B\n");if(a + b <= cb) {b += a, a = 0;}else a = a + b - cb, b = cb;}}} return 0;}
0 0
- UVA - 571 - Jugs (数论 - 经典倒水问题)
- UVA 571 Jugs(经典倒水问题)
- uva 571 - Jugs(倒水问题)
- UVa 571 - Jugs (数论)
- (杯子倒水问题)Jugs(p1606)
- ZOJ 1005 Jugs (倒水问题)
- POJ 1606 Jugs 倒水问题
- poj 1606 Jugs and poj 3414 Pots(数组模拟BFS) uva 571 (数论)
- ZOJ 1005 Jugs 杯子倒水问题
- UVA571 - Jugs(数论)
- UVa 10603 - Fill,经典倒水问题+隐式图搜索+dfs
- uva 10603 Fill(倒水问题 BFS)
- Fill (Uva 10603 bfs 倒水问题)
- UVA 10603 Fill(倒水问题)
- Uva 倒水问题
- uva 10603 倒水问题
- uva 571 jugs
- UVA 571 Jugs
- hdu1754 I Hate It (区间最值)
- 动态规划之——拦截导弹(nyoj79)
- WebView与JS交互【中级】
- 系统加大硬盘容量方法
- C++在继承的构造函数和析构函数
- UVA - 571 - Jugs (数论 - 经典倒水问题)
- Best Time to Buy and Sell Stock
- 使用 CSS3 中的伪类渲染表格
- union中大小
- Factorial Trailing Zeroes - LeetCode 172
- 黑马程序员——IO流(下篇)
- Linux程序设计(Linux shell编程的例子:生成网页文件)
- 关于STM32在MDK环境下的宏定义设置
- Simultaneous Localization and Mapping (SLAM)讲义1