ZOJ Problem Set - 1005
注意,条件:B>=C 。应考虑B=C的情况。
#include<iostream>
using namespace std; int A,B,C; void jugs(int a,int b,int C)
{
if(b==C)
{
cout<<"success"<<endl; }
else if(b==B)
{
cout<<"empty B"<<endl;
jugs(a,,C);
}
else if(a==)
{
cout<<"fill A"<<endl;
cout<<"pour A B"<<endl;
if(A+b>=B)
{
a=A-(B-b);
cout<<"empty B"<<endl;
jugs(a,,C);
}
else
{
jugs(,b+A,C);
}
}
else
{
cout<<"pour A B"<<endl;
if(a+b>=B)
{
a=A-(B-b);
cout<<"empty B"<<endl;
jugs(a,,C);
}
else
{
jugs(,a+b,C);
}
}
return; } int main()
{
while(cin>>A>>B>>C)
{ if (A==C)
{
cout<<"fill A"<<endl;
cout<<"success"<<endl;
continue;
}
if (B==C)
{
cout<<"fill B"<<endl;
cout<<"success"<<endl;
continue;
}
jugs(,,C);
}
return ;
}
1.需找bug,参考:
http://www.cnblogs.com/phinecos/archive/2008/09/21/1295472.html
ZOJ Problem Set - 1005的更多相关文章
- ZOJ Problem Set - 3829Known Notation(贪心)
ZOJ Problem Set - 3829Known Notation(贪心) 题目链接 题目大意:给你一个后缀表达式(仅仅有数字和符号),可是这个后缀表达式的空格不幸丢失,如今给你一个这种后缀表达 ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1025解题报告
ZOJ Problem Set - 1025 题目分类:基础题 原题地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=10 ...
- ZOJ Problem Set - 2563 Long Dominoes 【如压力dp】
称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 ...
- ZOJ Problem Set - 3593 拓展欧几里得 数学
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...
- ZOJ Problem Set - 2297 Survival 【状压dp】
题目:ZOJ Problem Set - 2297 Survival 题意:给出一些怪,有两个值,打他花费的血和能够添加的血,然后有一个boss,必须把小怪全部都打死之后才干打boss,血量小于0会死 ...
- ZOJ Problem Set - 3820 Building Fire Stations 【树的直径 + 操作 】
题目:problemId=5374" target="_blank">ZOJ Problem Set - 3820 Building Fire Stations 题 ...
- ZOJ Problem Set - 3229 Shoot the Bullet 【有上下界网络流+流量输出】
题目:problemId=3442" target="_blank">ZOJ Problem Set - 3229 Shoot the Bullet 分类:有源有汇 ...
- ZOJ Problem Set - 3822Domination(DP)
ZOJ Problem Set - 3822Domination(DP) problemCode=3822">题目链接 题目大意: 给你一个n * m的棋盘,每天都在棋盘上面放一颗棋子 ...
随机推荐
- 题解 [51nod1385] 凑数字
题面 解析 首先设\(n\)有\(l\)位, 那么对于前\(l-1\)位,\(0\)~\(9\)都是要选上的, 而对于最高位上的数\(x\),\(1\)~\(x-1\)也是要选上的. 到这里就有了\( ...
- 【Android-布局复用】 多个界面复用一个布局文件(一)
1.layout_common.xml 复用的布局文件 <?xml version="1.0" encoding="utf-8"?> <!-- ...
- windows 查看端口占用和杀死进程
在windows命令行窗口下执行:C:\>netstat -aon|findstr "3306" 如上图,端口被进程号为5056的进程占用,继续执行下面命令:C:\>t ...
- hover([over,]out)
hover([over,]out) 概述 一个模仿悬停事件(鼠标移动到一个对象上面及移出这个对象)的方法.这是一个自定义的方法,它为频繁使用的任务提供了一种“保持在其中”的状态. 当鼠标移动到一个匹配 ...
- http communication process
- Go中&和*的区别
& 返回变量的内存地址 * 返回变量的值, * 只能作用在指针上 package main import "fmt" func main() { var a = 5 var ...
- Python面试题:使用栈处理括号匹配问题
括号匹配是栈应用的一个经典问题, 题目 判断一个文本中的括号是否闭合, 如: text = "({[({{abc}})][{1}]})2([]){({[]})}[]", 判断所有括 ...
- Ubuntu切换登录用户和root用户
https://blog.csdn.net/master_ning/article/details/80733818
- 预处理、const、static与sizeof-使用宏定义得到一个数组所含的元素个数
1:代码如下: #define ARR_SIZE(a) (sizeof((a)) / sizeof((a[0])))
- iOS (APP)进程间8中常用通信方式总结
1 URL Scheme 2 Keychain 3 UIPasteboard 4 UIDocumentInteractionController 5 local socket 6 AirDrop 7 ...