Businessman crossing the river mathematical model source program

zhaozj2021-02-16  87

Title: Three businessmen have taken a river, a small ship can accommodate two, and they can spend themselves. Easy, in the river, once the number of people followed by the merchant, killing the goods. But how to take the power of the ship's trace in the hands of the businessman, how can the business people can safeize the river?

Solving: Mathematical Model: Remembering the number of business people on the shore of the kth Khaif River as XK, followed by YK, K = 1, 2, 3 .... The two-dimensional vector SK = (xk, yk) is defined as a status. The status set under the conditions of the safety river is called the allowable state collection, which is not difficult to write.

S = {(x, y) | x = 0, y = 0, 1, 2, 3; x = 3, y = 0, 1, 2, 3; x = y = 1, 2} {1}

The number of people on the kth trip ship is UK, followed by VK. Define two-dimensional vector DK = (UK, VK) as a decision. Allow decision-making collection to do D, can be known from the capacity of the boat

D = {(U, V) | U V = 1, 2} {2}

Because K is a odd number, the boat drives from the other side, k is the bilateral shore, so the state SK will change the decision DK change.

S (k 1) = SK (- 1) ^ k * DK {3}

{3} is called a status transfer law. Therefore, the development of the security ferry river program is attributed to the following multi-step decision issues: Decision DK belongs to D (k = 1, 2, 3, ..., n), so that the state SK belongs to S according to the transfer law {3}, from the initial State S1 = (3, 3) is reached by a limited step N to the state S (n 1) = (0, 0)

Design a program, solicited by the above ideas, the code is best c (end)

Entry: Yitian QQ: 12872678 E-mail: nutting@163.com 2004.07.27 Excerpt from: Mathematical Model (Second Edition) Jiang Qiyuan Higher Education Press ISBN 7-04-004502-2

转载请注明原文地址:https://www.9cbs.com/read-12606.html

New Post(0)