Under construction

Still being built. Things may change

Hypercube

Time limit0.2sMemory limit1024 MB

Summary
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 2N2^N nodes labeled with the numbers from 0 to 2N−12^N - 1. There is an arc from node xx to node yy if and only if x<yx < y and there is a non-negative integer pp such that x⊕y=2px \oplus y = 2^p, where ⊕\oplus is bitwise xor.

Given three positive integers NN, MM, and KK, compute the following.

  1. The maximum label ii of a node belonging to the N-hypercube that has an arc from ii to MM.
  2. The minimum label jj of a node belonging to the N-hypercube that has an arc from MM to jj.
  3. The number of paths of length KK (paths having KK 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 NN, MM, and KK, 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

  • 2≤K≤N≤100,0002 \le K \le N \le 100{,}000
  • 1≤M≤100,000,0001 \le M \le 100{,}000{,}000
  • For any given MM, there is at least one arc leaving node MM and at least one arc reaching node MM.
  • The answer for task 3 must be computed modulo 100003.
  • ⊕\oplus stands for bitwise xor.

Examples1

  1. Example 1

    Input
    4 3 2
    
    Expected output
    2
    7
    48