Nimbo Game (Nimm game)

Source: Internet
Author: User
Tags bitwise

Nimbo (nimm game): There are three piles of various items, two people take turns from a heap of any number of
Articles, the provisions of at least one at a time, more than open, and finally the winner of the light wins.

This is the most interesting situation, it is closely related to the binary system, we use (a,b,c) to denote a situation, first (0,0,0) is clearly a singular situation, no matter who face the singular situation, will inevitably fail. The second singular situation is
(0,n,n), as long as the opponent to take away as many items, will eventually lead to (0,0,0). It is also a bizarre situation, no matter how the opponent takes it, the next thing that can be changed (0,N,N)
Shape.

There is a computer algorithm called bitwise modulo 2 Plus, also called XOR, we use the symbol (+) to denote this operation. The difference between this operation and the general addition is 1+1=0. First look at the knot of the bitwise modulo 2 plus
Fruit:

1 = Binary 01
2 = binary 10
3 = Binary 11 (+)
———————
0 = binary 00 (Note no rounding)

As for the singular situation (0,n,n), the result is also 0.

Any singular situation (a,b,c) has a (+) b (+) c = 0.

If we are faced with a non-singular situation (a,b,c), how to become a singular situation? Suppose a < b< C, we just change C to a (+) B, because we have the following results: A (+) b (+) (A (+)
b) = (A (+) a) (+) (b (+) b) =0 (+) 0=0. To change C to a (+) b, simply subtract C-(a (+) b).

Example 1. (14,21,39), 14 (+) 21=27,39-27=12, so take 12 objects from 39
To the singular situation (14,21,27).

Example 2. (55,81,121), 55 (+) 81=102,121-102=19, so take 19 items from 121
A singular situation was formed (55,81,102).

Example 3. (29,45,58), 29 (+) 45=48,58-48=10, removed 10 from 58, changed to (29,4
5,48).

Example 4. Let's actually take a game to see:
A: (7,8,9) (1,8,9) Strange situation
B: (1,8,9) (1,8,4)
A: (1,8,4) (1,5,4) Strange situation
B: (1,5,4) (1,4,4)
A: (1,4,4) (0,4,4) Strange situation
B: (0,4,4) (0,4,2)
A: (0.4,2) (0,2,2) Strange situation
B: (0,2,2) (0,2,1)
A: (0,2,1) (0,1,1) Strange situation
B: (0,1,1) (0,1,0)
A: (0,1,0) (0,0,0) Strange situation
Jia Sheng.

Title 1: There are a number of matches, the two take it in turn, the rules can only be taken from a pile of several roots at a time,
Can be a bunch of all take away, but not to take, and finally take the end of the victory, to win the method.
Title 2: There are a number of matches, the two take it in turn, the rules can only be taken from a pile of several roots at a time,
Can be a bunch of all take away, but not to take, and finally take the end of the negative, to win the method. Hey, I've seen this game before. Childhood use Abacus Play this game: first gear dial one, second gear dial two, and then until the Fifth Gear dial five. Then two people took turns to pull the pieces down, who would win if the last one dialed. One summer when I saw two kids playing this game, I was wondering if there was a verdict. Let's try to prove it. Let's solve the first question first. Definition: If all matches are different or 0, then the state is called altruistic, denoted by the letter T;
As a self-interested state, expressed in S. [Theorem 1]: For any of the S states, you can always remove from a bunch of matches to make it a T state. Proof:     If there are n stacks of matches, each match has a (i) root match number, then since now in the S state,        C = A (1) Xor A (2) XOR ... xor a (n) > 0;     C is represented as a binary, remembering that the highest bit of its binary number is the P-bit, then there must be a (t), and its binary P-bit is also 1. (Otherwise, if all the P-bits of a (i) are 0, this is also 0 contradictory to the P-bit of C).     so we put x = A (t) Xor C, we get x < A (t). This is because since the P-bit of a (t) is 1 with the P-bit of C, the P-bit of x becomes 0, and the bit above p does not change. So x < A (t). and      A (1) Xor A (2) XOR ... xor x XOR ... xor a (n)    = A (1) Xor A (2) XOR ... xor a (t) XOR C XOR ... xor a (n)    = A (1) Xor A (2) XOR ... xor a (n) xor A (1) Xor A (2) XOR ... xor a (n)    = 0 That means Removing a (t)-X matches from the A (t) heap will change from S state to T state. Proof [theorem 2]:t state, take any pile of several roots, will become the S state. Proof: Try it with contradiction.       if        C = A (1) Xor A (2) XOR ... xor a (i) XOR ... xor a (n) = 0;        C ' = A (1) Xor A (2) XOR ... xor a (i ') XOR C xor ... xor a (n) = 0;       has c xor c ' = A (1) Xor A (2) XOR ... xor a (iXor A (N) xor A (1) Xor A (2) XOR ... xor a (i ') XOR C xor ... xor a (n) = A (i) Xor a (i ') =0       Then a (i) = a (i ') is introduced, which is in contradiction with the known. So the proposition is to be proven. [Theorem 3]:s state, as long as the method is correct, must win.]   
The final victory is changed from the S state to the T state, any one S state, as long as it becomes T-state, (by the theorem 1, it can be turned into a T state. The other party can only change the T state to the S state (theorem 2). In this way, all the transitions of s state to T state can be controlled by their own, and the other side can only passively realize the transition from T state to S state. So the S state must win.
[Theorem 4]:t state, as long as the method is correct, will fail.
By theorem 3 is easy to get. Then we will solve the second problem. Definition: If there are only 1 matches in a heap, it is called a solitary heap. If it is greater than 1, it is called an ample heap. Definition: In T-state, if the heap number of sufficient heap is greater than or equal to 2, then it is called full altruism, expressed in T2, if the heap number of ample heap equals 0, then it is called partial altruistic state, expressed as T0.
The root number of a lonely heap is different or only affects the last one in the binary, but the abundance heap affects the high (not the last). An abundance heap, the high must have a not 0, then all the root number is different or not 0. So it's not a T-state. [Theorem 5]:s0 state, that is, only an odd number of lonely heaps, will fail. T0 state to win.
Proof: S0 state, in fact, can only take one at a time. Every time the odd root is taken, the first even root is
The last one must be taken. Defeat. Similarly, T0 state win # [theorem 6]:s1 state, as long as the method is correct, win.
Proof: If at this time the number of lonely heap is odd, the ample heap is taken out; otherwise, take it to a root. In this way, it becomes an odd number of lonely heaps, taken by each other. By theorem 5, the other party will lose.   To win. # [theorem 7]:s2 states cannot turn once into T0 states.]
Proof: The abundance of heaps cannot be changed from 2 to 0 at a time.   Evidence. #

[Theorem 8]:s2 state can be changed to T2 state once.
It is proved that the 1,s state of the theorem can be changed to T state, the state can be changed to T state once, and the 6,s2 state of the theorem cannot be changed to T0 state once, so the T state of the transition is T2 state. # [theorem 9]:t2 state, can only be changed to S2 State or S1 state.
It is proved that the 2,t state of the theorem must change to S state. Since the abundance of heaps cannot be changed from 2 to 0 at a time, the S-state cannot be a S0 state at this time. The proposition is to be proven.
[Theorem 10]:s2 state, as long as the method is correct, win.
Proof: The method is as follows:
1) S2 The state, turn it into a T2 state. (by theorem 8)
2) The other party can only T2 into S2 State or S1 State (theorem 9)
If you turn to S2, turn 1)
If it turns into a S1, it's a win. (theorem 5)
[Theorem 11]:t2 state must lose.]
Proof: With 10.
In summary, must lose the state has: T2,S0
Win state: S2,s1,t0.
Compare two questions:
The whole process of the first question is actually as follows:
S2->t2->s2->t2->.->t2->s1->t0->s0->t0->......->s0->t0 (all 0)
The whole process of the second question is actually as follows:
S2->t2->s2->t2->.->t2->s1->s0->t0->s0->......->s0->t0 (all 0)
The underscore indicates the winning party's extraction. Whether they have found their striking resemblance.
It is not difficult to find (see Add Black section), the S1 state can be transformed into a S0 state (the second method), can also be turned into
T0 (first question procedure). Which side controls the S1 state, he can have the means to get the last one (turn into
T0), you can also make the other party get the last one (turn to S0).
So, robbing S1 is the key to winning.
To this end, always T2 state to each other, will make the other side in a passive state, he will sooner or later turn the state into S1.


Recommended Hdoj Topics
http://acm.hdu.edu.cn/showproblem.php?pid=1907
http://acm.hdu.edu.cn/showproblem.php?pid=2509
After reading the above conclusions, we can successfully solve the above 2.

S-nim
http://acm.hdu.edu.cn/showproblem.php?pid=1536
http://acm.hdu.edu.cn/showproblem.php?pid=1944

Game Algorithm Entry section 1536 1517 1907
Boy has been lost in the game recently ... Feeling quite deep.
In order to let everyone in the learning game time less detours, the most important is to deepen their own influence, warm so know new, special hair this paste with everyone. The
Learning game begins with the concept:
Special Recommendation LCY Teacher's courseware: game introduction.
Download Address: http://acm.hdu.edu.cn/forum/read.php?tid=6875
This courseware personally thinks from the basic idea of the game, has been to the solution Game Center algorithm to do the very good explanation. But it's especially important to note that. The lecture notes written in English at the back of the courseware are the most serious. Boy English is very weak, in this troubled for a long time. Now let's give you a general introduction. The
is primarily a question of the successor and SG values:
SG value: The SG value of a point is the smallest integer greater than or equal to zero that is not equal to its successor.
Successor point: that is, according to the requirements of the method (such as the number of stones can be taken, method) can go one step to achieve that point.
specific about the value of the SG is how to use the hope that you think more. There is a 1536 code behind the
Courseware. Can be placed in the back to do the
see here recommend you do a few questions: 1846 (the simplest game water)
1847 (for the SG value)

With the above knowledge next we take a look at the combination game (n heap stone)
recommend you see a material:
Game-Take stone game (recommended level five-star)
Http://acm.hdu.edu.cn/forum/read.php?fid=20 &tid=5748
Http://hi.baidu.com/netnode/blog/item/30932c2edc7384514fc226ea.html
Here presents a singular state of the problem. Read this article and you will find the beauty of the use of XOR in the game. Of course, this point is only a special case in the combination game. The
is still the solution to the value of the SG, but it is helpful to know that such a thought is undoubtedly of great breadth and depth of thinking.
ZZ Game
http://acm.hdu.edu.cn/forum/read.php?fid=9&tid=10617
The two big types of groups and games are described here, One is the last to take is N state one is the last to take the P-state, two states of the problem-solving method can understand very helpful. Of course, be able to understand the derivation process, thoroughly understand is undoubtedly the practice of the Daniel class ~ Boy also admire the tight ~   
    1536 recommended to do this question, the question before remind everyone is a question to ask the value of the SG, Front of the topic is a good explanation for the use of XOR or operation in combinatorial game problems. Of course the topic itself is different. Because there is a requirement to face the extraction here. So it returns to the solution of the game problem of the kingly algorithm--to find the value of the SG.
    The game topics for using the SG value are: 1850 (can also be based on singular state xor)
1848 (the typical problem of the large Fibonacci sequence)
1517 (personally think a little wretched topic ....) It's been bothering you for a long time. Of course it's fun to get out. The boy is to use the rules of the method to find the value of the SG, but the forum has been introduced to the law, here admire, we can learn about it
1079 (more wretched topic, the demand for novice higher, because the traditional method requires more detailed simulation plus the consideration of the corner state, Also someone pushes out the formula)
when you've finished reading all of the above stuff. Finish the above questions ... Boy, congratulations, you're getting started with the game ~ ~ ~
    Here the boy told us. The game is very powerful. Learn to be patient ~ Thank you
current System time:2008-12-11 19:16:03

ACM class Job:
1001 Brave Game
1002 good Luck in CET-4 everybody!
1003 Fibonacci again and again
1004 Rabbit and Grass
1005 Being a good boy on Spring Festival
1006 public sale 
1007 Mourning for 512 Wenchuan earthquake victims--selection of volunteers  
1008 Kiki ' s game 
1009 Calendar game 
1010 A multiplication game 
1011 Digital deletions 
1012 S-nim
Http://acm.hdu.edu.cn/forum/read.php?tid=11339&fpage=0&toread=&page=1

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.