1 0 2 0 = a3. A⊕b = b⊕a4. A⊕b⊕c = A⊕ (b⊕c) = (a⊕b) ⊕c; 5. D = A⊕b⊕c can be introduced a = d⊕b⊕c. 6. a⊕b⊕a = B. 7 if x is a binary number 0101,y is the binary number 1011 then x⊕y=1110 only if the two compared bits are not the same as the result is 1, otherwise the result is 0 i.e. "two inputs are 0, the difference is 1"!
In reality, the decimal values are used, so let's take a look at how the two decimal values are different or calculated: 5⊕2 =? 1. The values are converted to binary before the XOR or calculation: 5 and 2 to binary, respectively: 0101, 00102. Then convert the result 0111 to decimal: 73. So 5⊕2 = 7skillfully used
Unlike other languages, the C and C + + languages differ or do not have XOR, but instead use "^" and type as shift+6. (While the "^" in other languages generally denotes a exponentiation), if you need to exchange the values of two variables, in addition to the commonly used borrowing intermediate variables to exchange, you can also use XOR, only two variables to exchange,
a=a^b;b=b^a;a=a^b;
Mr. Ma wrote,.... on the blackboard.
Now step into the subject and begin to say this question. ____________________________________________
Find your Present (2) Time Limit: -/ +MS (java/others) Memory Limit:32768/32768K (java/Others) Total submission (s):19349Accepted Submission (s):7494problem DescriptionIn theNewYear party, everybody'llGetA"Special Present". Now it's your turn to get your special present, a lot of presents now putting on the desk, and only one of the them would be yours . Each present have a card number on it, and your present's card number would be is the one that different fromAll the others, and you can assume this only one number appear odd times. For example, there is5Present, and their card numbers are1,2,3,2,1. So your present'll be is the one with the card number of3, because3 isThe number that different fromAll the others. Inputthe input file would consist of several cases. each CaseWould be presented by an integer n (1<=n<1000000, and N isOdd) at first. Following that, n positive integers'll be giveninchA line, all integers'll smaller than2^ to. These numbers indicate the card numbers of the PRESENTS.N =0ends the input. Outputfor each Case, Output an integerinchA line, which isThe card number of your present. Sample Input51 1 3 2 231 2 10Sample Output32Hinthint use scanf to avoid time Limit exceeded
#include <stdio.h>intMain () {intn,a,m; while(SCANF ("%d",&N) {scanf ("%d",&a); N--; while(n--) {scanf ("%d",&m); A=a^m; } printf ("%d\n", a); } return 0;}
_____ Xor or Operation _________________________2095_____________________________________________