#arc139f. [arc139_f]Many Xor Optimization Problems
[arc139_f]Many Xor Optimization Problems
Problem Statement
PCT made the following problem.
Xor Optimization Problem
You are given a sequence of non-negative integers of length : . When it is allowed to choose any number of elements in , what is the maximum possible of the chosen values?
Nyaan thought it was too easy and revised it to the following.
Many Xor Optimization Problems
There are sequences of length consisting of integers between and . Find the sum, modulo , of the answers to Xor Optimization Problem for all those sequences.
Solve Many Xor Optimization Problems.
What is bitwise ?
The bitwise of non-negative integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if exactly one of and is , and otherwise.
For example, we have (in base two: ).
Generally, the bitwise of non-negative integers is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$. We can prove that this value does not depend on the order of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 1
Sample Output 1
3
We are to solve Xor Optimization Problem for all sequences of length consisting of integers between and .
- The answer for is .
- The answer for is .
- The answer for is .
- The answer for is .
Thus, the final answer is .
Sample Input 2
3 4
Sample Output 2
52290
Sample Input 3
1234 5678
Sample Output 3
495502261