Hypercube
Time limit0.2sMemory limit1024 MB
On the N-hypercube whose arcs join labels differing in one bit, find the largest predecessor and smallest successor of M, then count all paths of length K.
- Level
Medium7 of 10
- Topics
- Combinatorics, Bit manipulation, Math, Dynamic programming
- Solved
- No attempts yet
Problem
The N-hypercube is a directed acyclic graph with nodes labeled with the numbers from 0 to . There is an arc from node to node if and only if and there is a non-negative integer such that , where is bitwise xor.
Given three positive integers , , and , compute the following.
- The maximum label of a node belonging to the N-hypercube that has an arc from to .
- The minimum label of a node belonging to the N-hypercube that has an arc from to .
- The number of paths of length (paths having arcs) found in the N-hypercube. Because this number may be quite large, compute it modulo 100003.
Input
The first line of the input contains the three numbers , , and , each separated by one space.
Output
The first line must contain the answer for task 1, the second line the answer for task 2, and the third line the answer for task 3.
Constraints
- For any given , there is at least one arc leaving node and at least one arc reaching node .
- The answer for task 3 must be computed modulo 100003.
- stands for bitwise xor.