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的棋盘,每天都在棋盘上面放一颗棋子 ...
随机推荐
- javascript内置对象一:String
<script> //string.split("-"),以字符"-"把string拆分成一个数组.返回一个数组 //array.joi ...
- hybird(h5)页面自动化测试
- js中showModalDialog的使用
基本介绍: showModalDialog() (IE 4+ 支持) showModelessDialog() (IE 5+ 支持) ...
- 洛谷P4317 花神的数论题
洛谷题目链接 数位$dp$ 我们对$n$进行二进制拆分,于是就阔以像十进制一样数位$dp$了,基本就是套模板.. 接下来是美滋滋的代码时间~~~ #include<iostream> #i ...
- SVN - Subversion
Subversion yum install -y subversion 或者 subversion Edge 下载: # wget https://downloads-guests.open.col ...
- luogu3629
P3629 [APIO2010]巡逻 题目描述 在一个地区中有 n 个村庄,编号为 1, 2, ..., n.有 n – 1 条道路连接着这些村 庄,每条道路刚好连接两个村庄,从任何一个村庄,都可以通 ...
- Python实用黑科技——以某个字段进行分组
需求: 当前有个字典实例,你想以某个字段比如”日期”对整个字典里面的元素进行分组. 方法: itertools.groupby()函数是专门用来干这个活的.请看下面这个例子,这里有一个列表构成的字典, ...
- input输入框只能输入数字和英文逗号
<input type="text" onkeyup="this.value=this.value.replace(/[^\d\,]/g,'')"> ...
- spring事务之事务传播机制和隔离级别
Spring事务传播行为 运用Spring事务,必须要深入理解它的传播机制,否则会遇到各种意想不到的坑,Spring定义了七种传播行为. public interface TransactionDef ...
- 使用Pillow(PIL)库实现中文字符画
上班摸鱼写的,不多说了,直接上脚本 #coding=utf-8 from PIL import Image from PIL import ImageDraw from PIL import Imag ...