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

XOR

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $a$ consisting of $n$ non-negative integers. Count the number of pairs $1 \le i, j \le n$ such that $a_i \le (a_i \oplus a_j) \le a_j$. ### Input - The first line contains an integer $n$. - The second line contains $n$ positive integers $a_i$. ### Output - Print a single integer — the number of valid pairs $i,j$. ### Constraints - $1 \le n \le 5 \times 10^5$. - $0 \le a_i < 2^{30}$. ### Example Input: ``` 5 0 1 2 3 4 ``` Output: ``` 6 ```
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
Math
Rating 1400
Solution (3) Solution