report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Cyclic shift - FlandreOJ: Flandre Online Judge

Cyclic shift

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ consisting of non-negative 32-bit integers. Two integers in the array are considered similar if one number can be obtained from the other by performing some cyclic shift operations (which may not be performed at all). For example, for the positive integer $5$ with a binary representation of `0000 0000 0000 0000 0000 0000 0000 0101`: - After one right cyclic shift, we get the number `1000 0000 0000 0000 0000 0000 0000 0010`. - After one left cyclic shift, we get the number `0000 0000 0000 0000 0000 0000 0000 1010`. Count the number of pairs $i < j$ such that $A_i$ and $A_j$ are two similar numbers. ### Input - The first line contains an integer $n$. - The second line contains $n$ non-negative integers $A_i$. ### Output - Output an integer representing the number of pairs of similar numbers. ### Constraints - $1 \le n \le 10^5$. - $0 \le A_i < 2^{32}$. ### Example Input: ``` 7 128 786432 131072 1610612736 1536 4194304 50331648 ``` Output: ``` 9 ```
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 1400
Solution (2) Solution