Game problem analysis and mathematical induction

Source: Internet
Author: User

A, A and B play games, there are n cards, each time can only take a single prime number of power (such as 1,2,3,4,5 can and 6 not because of the 6=2*3, not a single prime number of power), a first come, and then take turns, and then take the last one to win, now given n cards, determine who wins under the best strategy.

Start with the simplest situation and find the rules:

1. When n=1,2,3,4,5, obviously a win, because at this time a can take the light, here to 1,2,3,4,5 such a win N is called "Win state."

2. When the n=6, a loses, at this time a can not all take light, and no matter how many a, the remaining B can all take the light, 6 such a situation is called "must lose state", obviously must lose the state can not be taken out at once.

3. It can be inferred that when the n=6+1,2,3,4,5=7,8,9,10,11 a to win, because a as long as the 1,2,3,4,5 each can be sent to the B will be 6, then B lose; Similarly, n=12, a cannot take a certain number (here "a certain number refers to 6" Generates a 6 to B, instead he can only throw a winning state to B.

4. Here we can find the law, when n is a multiple of 6, a loses, otherwise a wins, then the second mathematical induction to prove that the "is and only" a multiple of 6:

1) When the n<=6, the calculation can be the loss of the state is and only a multiple of 6;

2) Assume that the n<=6k is a multiple of 6;

3) Then when N=6 (k+1), if n is not a must lose state, then it must be reduced by a number to get 6 of the multiples (by assuming that the 6k is a must lose state), since n itself is a multiple of 6, then it must be reduced by a <=6k of 6 multiples, by the hypothesis, <= The number of multiples of 6k 6 is a must lose state, and 6 (k+1) can not take away the state card, that is, can not be done, so n=6 (k+1) is also a must lose state, when 6k<n<6 (K+1), a as long as take off a pass Zhang will be able to lose the state n=6k this will be sent to B, so B, by 3) It is known that when N<=6 (k+1), the required state is and is only a multiple of 6.

(1), 2), 3).

Therefore, this method is: if n is a multiple of 6, a WINS, otherwise B wins (the subject is not focused on the power of a single prime number of this condition, and 6k contains 6 of this factor, is bound to not meet the conditions);

Second, A and B play games, a total of n cards, two people take turns, a first come, ask a first take the number of >=1 and <=n-1 (that is, the first time can not take a picture can not get a full take), and then two people take, at least one and at most of the previous person Zhang number twice times (can be equal), The person who took the last card wins, now given n cards, judging who wins under the best strategy?

First of all, it is necessary to make clear that the lower limit of the card is 1, and the upper limit is determined by two factors: a. The upper limit is twice times that of the previous person, B. The implicit upper limit is less than 1/3 of the existing card, otherwise the next time the other party takes it out.

Also start from the simplest, find the law:

When 1.n=1,2,3, a loses;

N=4, a take 1, b either or 2 (most) lose;

2.n=5, a lose, because a to meet the B cap, can only take <5/3=1.3 Zhang, that a can only take 1 Zhang (will not lose), and at this time equivalent to his 4 to throw to B,b win;

3.n=6, a win, because B Upper limit is n<6/3=2,a can only take 1, a take 1 Zhang will 5 this will lose the state to B let B lose;

N=7, a win, a of the B upper limit n<7/3=2.3,a take 2 Zhang and 5 This will lose the state throw to B,a win again;

N=8, a loss, at this time a of the B cap for <8/2=2.7,a no matter take 2 or 1, will give B a win state, B wins;

4. Now we list the necessary loss of a that has been obtained: 1,2,3,5,8 can be found to be just part of the Fibonacci sequence, so we infer that when N is Fibonacci number, a loses (not sure words can be more than one of the above methods), then the second mathematical induction method to prove:

The first thing to know about Fibonacci numbers is two properties: 1. Any Fibonacci number (starting with the third item) can be expressed as the sum of the first two Fibonacci numbers (definition)

Http://baike.baidu.com/link?url=ia1is1HjHC_dLnVV8gxW4e6lJcAh_PHVFeRbK0sshP-q2BEDOscgbq-DRPBtjGXR7fzGCdUiQYfbPzLc1EWGuK

2. Ziekendorf theorem: Any positive integer can be expressed as a sum of several discontinuous Fibonacci numbers (excluding the first Fibonacci number).

Http://baike.baidu.com/link?url=L8Z022v3MVV7Ba0N13ghO9geTjmCsueAHgLFqG0Igw5TH3SraQG7smVuAkuC0fqWj1_dlBC_0OSRlnbJG6qq0K

Prove:

1) When the n<=8, the calculated must lose the state is and only the Fibonacci number;

2) assuming that n<=p (k) (P (k) is the K-Fibonacci number), the proven mode of transmission is and is only the Fibonacci number;

3) then n=p (k+1), because P (k+1) is the Fibonacci number, can be expressed as the first two Fibonacci number P (k-1), p (k) and the sum of the Yi Certificate p (k-1) >p (k)/3, that a 1th times the number is necessarily less than

P (k), from the assumption that P (k-1) is a must lose state, this must lose the state actually has a meaning, that is, B must be able to get P (k-1), at this time the remaining P (k) is also required (assuming) left to A,a lose.

When P (k) <n<p (k+1), n is not a Fibonacci number, but is known by the Ziekendorf theorem, n can certainly be decomposed into the sum of the non-adjacent Fibonacci numbers (note that is "not adjacent"!)

Suppose N=p (a) ... +p (b) +p (c) +p (d) (in descending order, p (d) the smallest), then by an nonadjacent p (d) <N/3, at which point a just take P (d), note that here by "nonadjacent" There are two important conclusions, one is P (d) <N/3 ( In fact, after taking P (d) The smallest items remaining are also satisfied, not discussed here), the second is P (c) >2*p (d), that is, a takes P (d), B cannot imitate a and then take P (c), and B is "caught" in the P (c) This must lose, and then as long as a has been guided B into the next must lose state until P (a), a wins. (b cannot make any resistance in this process), known by 4, when N<=p (k+1), Fibonacci number is a must-lose state, non-Fibonacci number is a winning state.

(1), 2), 3).

Therefore, this method is: If n is the Fibonacci number, a will lose, otherwise a win.

(currently included in these two questions, follow-up collection of other similar topics will be added to this blog in succession)

Game problem analysis and mathematical induction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.