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

xor xor xor

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers. Let's denote function $f(l, r)$ as: $$max(A_{l...r}) \oplus min(A_{l...r})$$ Calculate: $$ \sum_{l=1}^{n} \sum_{r=l}^{n} f(l, r) $$ ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the result, modulo $10^9+7$. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 4 1 4 3 1 ``` Output: ``` 29 ```
Divide and conquer
Product
Big board
Segment queries
xor xor xor
Coins flip
Slimes
4D longest path
Good subarray
Shortest path on grid
Dynamic MST
Topic
Bitmasks
Divide and conquer
Rating 2100
Solution (0) Solution