Title: Solve the river problem, it is best to have source code, thank you! Original postage: 2004 return
Author: none [onizuka] User Forum Replies Favorites
If there is N normal people and N mental illnesses to prepare a river, there is only one boat that can accommodate C person, in order to prevent mental patients from infringing normal people, requiring no matter where, the number of normal people must not be less than mental patients, unless Normal number is 0, and assume that two people will boast, try to design a algorithm, determine if they can spend the river, if you can, give a small number of boats to the best solution! [This post was None Onizuka) edited in 21:17 on September 27th]
I am onizuka
Global Published: 04-09-25 17:59
Reply: No [sniper167] forum users reply collection
To divide four situations: 1. N and C are even: Every time the normal and abnormal people are C / 2, then come back to normal and abnormal until they finish 2. N and C are odd: 3. N is even, C is Ciqi: 4. n is Qi, N is even: I don't write anything else. . .
In fact, I won't, but I don't understand! ! !
B1 layer Published: 04-09-28 16:23
Reply: Month Month [Kert_T8] Reply Favorites Modify Delete
Let Me Have a Try:) First, We Should Have A Data Structure So That We Could Store The Action The Are from A by Boat To C. So .... Def. Int A [2], B [2], C [2], Wnumber of Common People IS 1 * N, Stored In x [0] Number of silly is -1 * n, in x [1] w = 1 means boat is at a, w = 2 Means Boat IS AT CSO, WE Have Constraints: 1, X [0] X [1]> = 0 unless x [0] = 02, ABS (B [0]) ABS (B [1])
m trying. / //any Mistake Please Be Put Up You Find .......... (More Contents Should Be Put Up Several Day) to be continued .. ............ [This post was edited by the month of the month (kert_t8) edited at 03:40 on October 03] Chinese, speak Chinese, write Chinese characters, Xi Zhonghua Culture, Yanghua
B2 layer Published: 04-10-01 13:34
Reply: 20cn 悫 [Balsai] Forum users reply collection
Big house with C
20CN represents the Chinese people around 20 years old, in this age, our enthusiasm is burning for the motherland for the society, we tried to use the beautiful shoulders to take on their responsibilities. 20CN construction requires your participation, press this to update your document for the website
B3 layer Published: 04-10-01 14:04
Reply: none [onizuka] Forum users reply collection
Let's cheer! Help me!
I am onizuka
B4 layer Published: 04-10-02 16:05
Reply: Month Month [Kert_T8] Reply Favorites Modify Delete
OK, let's go on with what we talked about ..... As we have already said, the biggest problem of the algorithm above is, we are not sure if he can find an answer. And all the problems because of the sentence ' List = prepend (newstate, list) '. we Could See, IF We Always Put A Serial of New States At the Head of the List, And Pick The First One To Choose What Next Action Will Be. So, IF We change That Into 'list = APPend (newstate, list)', OK, problem sloved. (This is the Breadth-First search) The difference between the two algorithms is the first one is continue trying the First Action of NEXT step after he tried the first action of This step, but the latter one is try every possible actions in This step, and then, every actions in NEXT. It is important to make clear understanding on the difference, because we'll see later, this difference is a way which we Could Speed Up Our Algorithm.But, We Find The New Algorithm's Running Time IS O (M ^ n) (Where m is the number of choers and n is the number of Actions Which Should Be Exectue). Andiff We Conbine The Two Algorithm Together, We'll Found, The Running Time Is Still O (M ^ n). OK, Let's First See The New Algorithm ......... .. (We'll Also Do Some More Speed Up, No Revisiting State) List <- {a, b, c (state)}; while (list! = Empty) {// Not Necessarily Being Null Do S <-Head (List); if (s == specialstate) State <-pop (state); Until (s! = specialState) // specialstate is not a real state, but a mark to pop a state in stat. list <-rest List); state <-s; // We save this state into a state list if (s goal) return state; else if (state.length <=
Bound) {// bound is a value we set to determin We Must Solve The Problem in How Many Steps We Could Search. List <-prepend (SpecialState, List); // Make a Note That Search in A New Level Begin While (Action! = EMPTY) {// Action is a set in which there is all the actions could Apply on this state act <-head (action); newstate B5 layer Published: 04-10-03 03:37 Reply: Month Month [Kert_T8] Reply Favorites Modify Delete Sorry about some notation bugs in the first composition. That's because I was still not used to write pseudo-code. But in the following algorithm, I'll try my best to write correct code.Thank myself for first find these problems. And I 'm Sorryi Hope I Could Put on My First Program on this Problem asap. But i Have to Take Class for Futher Learning and It Take Time To Write The Program. So, Be Patient Chinese, speak Chinese, write Chinese characters, learn Chinese culture, Yang China B6 layer Published: 04-10-03 03:53 Reply: Month Month [Kert_T8] Reply Favorites Modify Delete I have repeatedly try it for a long time, but I don't do out the program, and then I found out that I have a problem with the understanding of the algorithm itself. The algorithm we finally discussed is actually incomplete. Everyone can see that the Bound of the program is the search of the layers, then it will decide. If the river's pace can't be done in Bound, then the program will think of this problem misunderstand, Wrong answer. And if the program executes within Bound, there is no difference with BackTrack Search, and there is no found shortest path for for (int bound = 1 ;; Bound ) {list <- {a, b, c (state)}; while (list! = EMPTY) {// not Necessarily Being Null Do S <-head (list); if (s == specialstate) State <-pop (state); until (s! = specialState) // SpecialState is not a REAL STATE, BUT A Mark to Pop A State In State. list <-rest (list); state <-s; // We save this state inal) Return State; Else IF (state. Length <= bound) {// bound is a value we set to determin We Must Solve The Problem in How Many Steps We Could Search. list <-prepend (SpecialState, List); // Make A Note That Search in a new level begin while (action! = EMPTY) {// action is a set in which there is all the a set in which there in this state act All feelings are found in self-study and completion of homework, including the algorithm error found above, all discovered when writing homework yesterday. If someone understands this algorithm, please help me explain it, I also learn to learn: Due to study "artificial intelligence", many algorithms are related to this solving problem, such as our homework, there is Huaying Road, and The reasoning of the proposition logic (I mean an advice to solve). There is also a royal party problem. It is solved. The reason why I chose this question is because I want to be 1 in this way. I can review the contents of the teacher and make me more experience in solving this problem (such a way to write homework) 2. I also want to introduce these algorithms to everyone, because I have found that we have rarely systematically accept this algorithm in China (at least I am so), most of the algorithms are tried to talk about the teacher, and a lot We didn't understand the essence of things that the teacher said. I am sorry that I haven't sticked the source program, but I have been very hard to do this. I hope that next time I can sneak all the Chinese, speak Chinese, write Chinese characters, learn Chinese culture, and Yanghua B7 layer Published: 04-10-15 02:03 Reply: GG [GG123] Forum users reply collection Foreign countries, you have glow! Also said that Chinese cultural Yang's martial arts ~~~~? ? 20CN is the construction of the civil non-profit network security organization 20CN needs your participation, and you can update your document for the website. B8 layer Published: 04-12-02 14:44 Reply: cold jade man [hannyu] Forum users reply collection Continue P. S. This supplemental English upstairs I am holding 20cn at the iron stone heart. B9 layer Published: 04-12-02 19:44 Reply: Month Month [Kert_T8] Reply Favorites Modify Delete I have already passed it, but I haven't come up for a while, the result is so long, and the original document is lost. No way, I rereaded one. (In order to write this procedure, I also found TA to return the previous job, because all the programs, including homework, is blocked), because it is new, in design, I mean the data structure, different, The structure of the previously designed positive and negative number is not easy, and it is not comfortable when the ship is located, so I made a State class, aside said in the shore of the A, cside is C shore. All arrays, [0] represents the number of normal people, [1] is the number of neuropathy, and it is expressed. Boat said the boat is on that, if it is -1 is C, 1 is A. File: River.javaimport java.util. *; Public class river {public static void main (string args []) {int Ninput; int Cinput; Do {system.out.print ("/ N / NWe Assume All./nlet's input the number n first.nlet'); ninput = getter.get (system.in);} while (Ninput < 1); do {system.out.print ("/ NAND You Must Decide the max load of the bag:"); cinput = getter.getint (system.in); if (Cinput <2) System.out.println "Do you think such a small bot could fulfill ou task, man?");} While (cinput <2); system.out.println (); int a [] = new int [2]; int C [] = New int [2]; a [0] = ninput; a [1] = ninput; c [0] = 0; c [1] = 0; state initstate = new state (a, c, 1, cinput); state GoalState = New State (C, A, -1, CINPUT); Bloop: for (int bound = 1 ;; Bound ) {system.out.println ("bound =" bound); Vector statelist = new vector (); Vector solution = new vector (); statelist.add (initstate); WLOOP: while (statelist.size ()> 0) {state nowState = new state (); do {ix (statelist.size () == 0) Continue BLOOP; NowState = (state) (statelist .remove (statelist.size () - 1)); if (nowState == null) Solution.remove (Solution.Size () - 1);} while (nowState == null); if (nowState.Stateequal (GoalState) ) {givesolution;} else if (Solution.Size ()> = bound) {amount}} else {solution.add (nowState); statelist.add (null); for (int i = 0; i < Cinput; i ) for (int J = 0; j ListIndex ) {if (newState.Stateequal ((state)))) {flag = false; break;}} f (statelist.size ()! = 0) for (int ListIndex = 0; LISTINDEX A.Length; i ) {this.aside [i] = a [i];} for (int i = 0; i }} I wanted to pack and then upload it. I have no choice but to have some functions, if I don't want to get lazy to the paste, please follow your fuel tank address, I will send you a good The above post, English, I will take the time to translate him, but it is not now, because now the end of the exam, I still want to review more time. I know that it is not good in English, but I have no way at the time. If you don't want to continue, I can continue. I will post our job questions later, which is about China's channel. Interested in doing it, I happened this time, so there is any problem to compare with my job, although there is no good choice but there is a similar search problem that can be referred to, is all Basic of artificial intelligence of chess games, there are several projects in our class to make a good game, I hope to have more people to figure out it in the source program, in order to simplify keyboard input, I use The source code of our database Project team, all the code in Getter.java is not what I wrote, the original author is Harry, and it is not possible to use it without the agreement. Harry should not be angry. Just here, go to class .... Chinese, speak Chinese, write Chinese characters, learn Chinese culture, Yang China B10 layer Published: 04-12-07 03:03 Forum: Programming Crack Back 20CN Network Security Group Copyright CopyRight © 2000-2004 20CN Security Group. All Rights Reserved. Forum program: NetDemon