742B.md (2232B)
1 Source: https://codeforces.com/problemset/problem/742/B 2 3 B. Arpa’s obvious problem and Mehrdad’s terrible solution 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 There are some beautiful girls in Arpa’s land as mentioned before. 22 23 Once Arpa came up with an obvious problem: 24 25 Given an array and a number *x*, count the number of pairs of indices *i*, *j* (1 ≤ *i* < *j* ≤ *n*) such that , where  is bitwise xor operation (see notes for explanation). 26 27  28 29 Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem. 30 31 Input 32 33 First line contains two integers *n* and *x* (1 ≤ *n* ≤ 105, 0 ≤ *x* ≤ 105) — the number of elements in the array and the integer *x*. 34 35 Second line contains *n* integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 105) — the elements of the array. 36 37 Output 38 39 Print a single integer: the answer to the problem. 40 41 Examples 42 43 Input 44 45 ``` 46 2 3 47 1 2 48 ``` 49 50 Output 51 52 ``` 53 1 54 ``` 55 56 Input 57 58 ``` 59 6 1 60 5 1 2 3 4 1 61 ``` 62 63 Output 64 65 ``` 66 2 67 ``` 68 69 Note 70 71 In the first sample there is only one pair of *i* = 1 and *j* = 2.  so the answer is 1. 72 73 In the second sample the only two pairs are *i* = 3, *j* = 4 (since ) and *i* = 1, *j* = 5 (since ). 74 75 A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: <https://en.wikipedia.org/wiki/Bitwise_operation#XOR>.