1005 Jugs, 1005 jugs
Get started. There is no optimal solution for two capacity questions.
1 #include<stdio.h> 2 3 int main(){ 4 int A,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 else22 sB=B;23 }24 else25 sA=0;26 }27 if(sB==T){28 printf("success\n");29 break;30 }31 }32 }33 return 0;34 }
A typical DP question is best created
Zju search dp question summary favorites
|
Search:
50 search questions
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 convex hull
1516 Uncle Tom's Inherited Land --- OK
1525 Air Raid may be more suitable for Network Flow Calculation
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? The search may be a bit controversial (no matter)
1940 Dungeon Master ---- OK
2100 Seeding ---- OK
2110 Tempter of the Bone
2140 Ball
(27)
The above questions may be relatively simple. Just practice basic algorithms.
========================================================== ========================================================
The following questions are not easy to do.
Difficulties & classic
1003 Crashing Balloon
1015 Fishing Net perfect image
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 graph Shortest Path to save
1492 Maximum Clique classical Graph Theory Algorithms-the largest group
1600 Market Place
1605 One-way Traffic
1568 WishingBone's Room Plan
1742 Gap has no idea so far. It's hard !!!
1743 Concert Hall Scheduling
1827 The Game of 31
1855 Maze
1903 Jogging Trails China mail routes
1909 Square classic dfs.
2064 Bomberman-Just Search! Classic!
2094 Max Angle Calculation ry + game
2125 Rocket Mania
2126 Rocket Mania Plus
2127 Zuma
2128 Seven Seas
2129 Mummy Maze
2142 Light The Square
(24 channels)
========================================================== ===
Dp
50 dp questions
1499 Increasing Sequenc ...... remaining full text>
Programming of the optimal Oil Separation Solution in C Language
Can you post the problem?
I made a ZOJ1005 question.
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 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
Fill B
Empty
Empty B
Pour A B
Pour B
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, ...... remaining full text>