51 1 3 6 631 2 1
Sample output
32
At first, I did not pay attention to the memory limit. I opened an array and recorded the ball number with the array subscript. In the final query, I used a [I] To get the remainder of 2. When the remainder is 1, output I. The overmemory is found only after submission.
Super MemoryCode:
# Include <stdio. h> # include <string. h> int A [1000002]; int main () {int N, I, m, Max; while (~ Scanf ("% d", & N) {memset (A, 0, sizeof (a); max = 0; for (I = 0; I <N; I ++) {scanf ("% d", & M); A [m] ++; If (M> MAX) max = m ;}for (I = 1; I <= max; I ++) if (a [I] & 1) {printf ("% d \ n", I); break ;}} return 0 ;}
Later, I heard people say that they can use an exclusive or nature for processing. I checked the exclusive or nature and wrote the code and submitted it to the AC.
Operation Rule for XOR: 0 ^ 0 = 0, 0 ^ 1 = 1, 1 ^ 0 = 1, 1 = 0
Specifically, convert the decimal number to the binary number (take 8 or 16 bits, and fill in 0 if not enough), and then each bit corresponds to an exclusive or operation, converting the result to a decimal number is an exclusive or result. For example, 9 ^ 5 = 12;
00001001 (binary representation of 9)
00000101 (binary representation of 5)
00001100 (the result after XOR is expressed as 12 in decimal format)
The Code is as follows:
# Include <stdio. h> int main () {int n, m, I, S; while (~ Scanf ("% d", & N) {S = 0; for (I = 0; I <n; I ++) {scanf ("% d ", & M); s ^ = m;} printf ("% d \ n", S);} return 0 ;}
Another method is to use the container in C ++ for processing. I think someone else wrote this as a reference. The Code is as follows:
# Include <stdio. h ># include <set> using namespace STD; int main () {int N, A, B, I; set <int> T; // define an int-type container while (scanf ("% d", & N )! = EOF) {B = 0; for (I = 0; I <n; I ++) {scanf ("% d", & A); If (T. find (A) = T. end () T. insert (a); // The container does not have the same content as a. Insert a else t. erase (a); // locate and delete all a} printf ("% d \ n", * t. begin (); T. clear (); // clear the container} return 0 ;}