Because exclusive or operations are often used in game theory, especially when sg functions are actually used, I will write down some related knowledge found on the internet and some of my own understandings.
If any error occurs, please point it out. Thank you!
Exclusive OR: it can be referred to as Xor. It can be expressed by the mathematical symbol "oplus". Generally, the computer can be expressed by ^.
Exclusive or operations mainly refer to binary.
0& Oplus;0 = 0,
0& Oplus;1 = 1
1& Oplus;0 = 1,1& Oplus;1 = 0It can be seen that the two values are the same as 0, and the difference is 1. Another method is to calculate the sum of two numbers, but not carry. For example, 1 & oplus; 1 = 0 can be regarded as 1 + 1 = 10, but not carry, so 1 & oplus; 1 = 0. Some operation rules
1. a & oplus; a = 0
2. a & oplus; B = B & oplus;
3. a & oplus; B & oplus; c = a & oplus; (B & oplus; c) = (a & oplus; B) & oplus; c;
4. d = a & oplus; B & oplus; c can launch a = d & oplus; B & oplus; c.
5. a & oplus; B & oplus; a = B.I will give an example to illustrate the application of Rule 5.
Example: We know that a string contains only numbers of int type integers greater than 0. Most of the numbers appear twice, but only one number appears once, evaluate the value of this number.
For example, numbers 5 5 3 2 2 1 3, numbers 5, 3, and 2 appear twice, and only 1 appears once, so the answer to this string of numbers is 1. For example, the answer to 3, 4, 5, 4, 2, and 3 is 2.For this question, you can use a hash array, but it may use too much space. It is much simpler to use an exclusive or. Because a & oplus; a = 0; 0 & oplus; B = B; a & oplus; B & oplus; a = B; for example, 5 5 5 3 2 1 3 exception or 5 & oplus; 5 & oplus; 3 & oplus; 2 & oplus; 2 & oplus; 1 & oplus; 3 = 5 & oplus; 5 & oplus; 3 & oplus; 3 & oplus; 2 & oplus; 2 & oplus; 1 = 0 & oplus; 0 & oplus; 0 & oplus; 1 = 1; the numbers 5, 3, and 2 that appear twice in the sequence are 0 when they are exclusive or, therefore, the number 1 that appears only once is obtained. Only one digit can appear if all numbers are different or different. In addition, this method greatly saves space and time.
Notes about exclusive or (Xor)