report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
XOR pair - MarisaOJ: Marisa Online Judge

XOR pair

Time limit: 1000 ms
Memory limit: 256 MB
In the array $A$ consisting of non-negative integers, count the number of pairs $i < j$ such that $A_i \oplus j = A_j \oplus i$, where $\oplus$ denotes the bitwise XOR operation. ### Input - The first line contains an integer $n$. - The second line contains $n$ non-negative integers $A_i$. ### Output - Print an integer representing the number of pairs that satisfy the given condition. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 5 7 8 9 14 3 ``` Output: ``` 4 ```
Bitwise operations
Trick-OR-Treat
Bitwise operations 1
Bitwise operations 2
Bitwise operations 3
XOR pair
Full
Range XOR
Cyclic shift
XOR
XORray
Minimum Xor Pair Query
Topic
Bitmasks
Rating 1200
Solution (2) Solution