1005 Jugs,1005jugs

辗转相减,新手入门题。两个容量的灌水题,无所谓最优解。

1 #include

2

3 intmain(){4 intA,B,T,sA,sB;5 while(scanf("%d %d %d",&A,&B,&T)>=0){6 sA=sB=0;7 while(1){8 if(sA==0){9 printf("fill A\n");10 sA=A;11 }12 else{13 printf("pour A B\n");14 sB+=sA;15 if(sB>=B){16 if(B!=T){17 printf("empty B\n");18 sA=sB-B;19 sB=0;20 }21 else

22 sB=B;23 }24 else

25 sA=0;26 }27 if(sB==T){28 printf("success\n");29 break;30 }31 }32 }33 return 0;34 }

一道DP经典题最好自创带标程

zju搜索dp题目总结收藏

|

搜索:

50道搜索题

1002 Fire Net -ok

1004 Anagrams by Stack -ok

1005 Jugs -ok

1008 Gnome Tetravex -ok but not ac

1091 Knight Moves -ok

1101 Gamblers -ok

1204 Additive equations

1221 Risk

1230 Legendary Pokemon

1249 Pushing Boxes

1364 Machine Schedule

1368 BOAT

1406 Jungle Roads ---ok

1411 Anniversary

1453 Surround the Trees 凸包

1516 Uncle Tom's Inherited Land ---ok

1525 Air Raid 算网络流问题可能更合适一点

1586 QS Network

1602 Multiplication Puzzle dp

1649 Rescue

1671 Walking Ant----ok

1711 Sum It Up dfs----ok

1901 A Star not a Tree? 说他搜索可能有点争议(不管了)

1940 Dungeon Master----ok

2100 Seeding ----ok

2110 Tempter of the Bone

2140 Ball

(27道)

上面的题可能比较简单,就当练练基本算法吧

===============================================================================

下面的题没有容易做的。

难题&经典

1003 Crashing Balloon

1015 Fishing Net 完美图

1144 Robbery

1149 Dividing up

1161 Gone Fishing

1197 Sorting Slides

1217 Eight

1228 Farewell, My Friend

1237 Fans and Gems

1455 Schedule Problem

1456 Minimum Transport Cost 图论 最短路径 要保存路径

1492 Maximum Clique 图论 经典算法--最大团

1600 Market Place

1605 One-way Traffic

1568 WishingBone's Room Plan

1742 Gap 至今一点想法都没有,难!!!

1743 Concert Hall Scheduling

1827 The Game of 31 博弈

1855 Maze

1903 Jogging Trails 中国邮路问题

1909 Square 经典的dfs.

2064 Bomberman - Just Search! 经典!

2094 Max Angle 计算几何+博弈

2125 Rocket Mania

2126 Rocket Mania Plus

2127 Zuma

2128 Seven Seas

2129 Mummy Maze

2142 Light The Square

(24道)

===========================================

dp

50道dp的题

1499 Increasing Sequenc......余下全文>>

C语言中的最佳分油方案程序设计

能不能把问题贴出来啊?

我做了一道ZOJ1005题,差不多吧

In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug with exactly 4 gallons. This problem generalizes that puzzle.

You have two jugs, A and B, and an infinite supply of water. There are three types of actions that you can use: (1) you can fill a jug, (2) you can empty a jug, and (3) you can pour from one jug to the other. Pouring from one jug to the other stops when the first jug is empty or the second jug is full, whichever comes first. For example, if A has 5 gallons and B has 6 gallons and a capacity of 8, then pouring from A to B leaves B full and 3 gallons in A.

A problem is given by a triple (Ca,Cb,N), where Ca and Cb are the capacities of the jugs A and B, respectively, and N is the goal. A solution is a sequence of steps that leaves exactly N gallons in jug B. The possible steps are

fill A

fill B

empty A

empty B

pour A B

pour B A

success

where "pour A B" means "pour the contents of jug A into jug B", and "success" means that the goal has been accomplished.

You may assume that the input you are given does have a solution.

Input

Input to your program consists of a series of input lines each defining one puzzle. Input for each puzzle is a single line of three positive integers: Ca, Cb, and N. Ca and Cb are the capacities of jugs A and B, an......余下全文>>

http://www.dengb.com/Cyy/889009.htmlwww.dengb.comtruehttp://www.dengb.com/Cyy/889009.htmlTechArticle1005 Jugs,1005jugs 辗转相减,新手入门题。两个容量的灌水题,无所谓最优解。 1 #includestdio.h 2 3 int main(){ 4 int A,B,T,sA,sB; 5 while (scanf( " %d %d...

c语言大小写字母互换1005,1005 Jugs,1005jugs相关推荐

  1. Bailian2689 大小写字母互换【文本】(POJ NOI0107-14)

    问题链接:POJ NOI0107-14 大小写字母互换. 大小写字母互换 总时间限制: 1000ms 内存限制: 65536kB 描述 把一个字符串中所有出现的大写字母都替换成小写字母,同时把小写字母 ...

  2. 1.7 编程基础之字符串 14 大小写字母互换 python

    http://noi.openjudge.cn/ch0107/14/ """1.7 编程基础之字符串 14 大小写字母互换 AC http://noi.openjudge ...

  3. OpenJudge NOI 1.7 14:大小写字母互换

    [题目链接] OpenJudge NOI 1.7 14:大小写字母互换 [题目考点] 1. 字符串 2. 大小写转换 'a'的ASCII码是97,'A'的ASCII码是65,同一字母的大小写字母的AS ...

  4. C语言大写字母E转小写e,C语言 大小写字母转换

    C语言 大小写字母转换 C语言大小写字母转换 1. 完成一个大小写字母自动转换的程序,输入大写字母,程序可以输出小写字母,输入小写字母,可以输出大写字母 #include int main() { c ...

  5. C语言——大小写字母转换

    C语言大小写字母转换 在 C 语言中区分字母的大小写,利用 ASCII 码中大写字母和小写字母之间的转换关系(差值为 32),可以将小写字母转换为大写字母. 1.小写转换大写 int main() { ...

  6. c语言首字母大小写字母转换,C语言大小写字母转换,C语言 大小写字母转换

    导航:网站首页 > C语言大小写字母转换,C语言 大小写字母转换 C语言大小写字母转换,C语言 大小写字母转换 匿名网友: #includevoid main(){char c1,c2: // ...

  7. C语言实现大小写字母互换

    1.单个字母的互换 基本思路:我们知道在char类型中,字符以ASCII码储存,而且大写字母从A到Z是65-90,小写字母从a到z是97-122,因此可以通过判断ASCII码的范围来确定大小写:不难看 ...

  8. c语言大小写字母相互转化,字母大小写互相转换 ASCII码转化符号问题

    字母大小写互相转换 ASCII码转化符号问题 请问在c语言中 字母大小写互相转换怎么编写? 请问为什么 #include void main() { char a,c; int b; printf(& ...

  9. 【C语言编程】 大小写字母互换

    描述 把一个字符串中所有出现的大写字母都替换成小写字母,同时把小写字母替换成大写字母.输入 输入一行:待互换的字符串. 输出 输出一行:完成互换的字符串(字符串长度小于80). 样例输入 If so, ...

最新文章

  1. B2B行业网站编辑轻松创造内容,提高搜索权重
  2. 筑算高程点提取插件_「教程」原来利用高程数据点建立地形模型,只需要一个键...
  3. php折线图 布局图
  4. leader选举的源码分析-runFromConfig
  5. metasploitable2渗透测试
  6. Linux php 中文乱码解决
  7. JWT操作工具类分享
  8. 数据科学入门与实战:玩转pandas之五
  9. webpack转内联px为rem_Vuejs项目配置webpack将px自动转化为rem,适配移动端
  10. [Android1.6]动态添加View的问题
  11. 计算2+22+222
  12. 解决戴尔电脑蓝牙消失问题
  13. HttpMessageNotReadableException: Required request body is missing:
  14. 【数据库】数据库入门(五): 实体关系模型 (Entity-Relationship Model)
  15. 展台设计:企业展台搭建都有哪些途径?
  16. 数据结构栈的操作,初始化栈,进栈,出栈,读取栈顶元素;
  17. riak mysql_Riak安装
  18. 关于目标检测中bounding box编码和解码时weight参数的理解
  19. iterm2安装记录
  20. 程序员必备技术网站及刷题网站 | Java我最强

热门文章

  1. matlab下的彩色图像转换成二值图像并保存
  2. 计算机二级是wpsoffice高级应用吗,考计算机二级ms office高级应用但是自己电脑上office软件都是wps 这和word ppt excel 软件有区别吗...
  3. 数据仓库系列(四)数仓架构以及多维数据模型的设计
  4. 机器学习(Machine Learning)深度学习(Deep Learning)资料(Chapter 2)
  5. 移动硬盘损坏,数据能恢复吗
  6. 除了青蛙旅行,我们还有哪些大事不是被机器人搞砸的?
  7. 图标字体的优缺点和使用
  8. 2019暑期在校培训总结
  9. 微软Azure 虚拟机支持多种 Linux 发行版!
  10. bag of tricks for image classification with convolutional neural networks