Primal Collection
시간 제한1초메모리 제한2048 MB
1..N+1에서 S를 뺀 값으로 이진 힙을 채우고 바닥에 S를 넣었을 때 정확히 K번 교환되는 배열의 수를 센다.
문제
You are given an array , which initially has a size of (indexed from to ) containing distinct integers with values between and inclusive. It is known that this array is primal, that is, for any index , will always be smaller than .
Denote as the value between and that does not appear in . You want to append one new element into , namely , with . Then, the following algorithm is executed.
algorithm(A):
x = N + 1
counter = 0
while x > 1:
if A[x] > A[floor(x / 2)]:
swap(A[x], A[floor(x / 2)]);
counter = counter + 1
x = floor(x / 2)
return counter
You want to calculate the number of possible values of the initial array such that when you append to and excecute algorithm(A), it will return . Note that the initial array contains distinct integers with values between and inclusive, excluding , and array has to be primal. As the answer can be very large, find the answer modulo .
입력
A single line consisting of three integers (; ; ).
출력
Output a single integer representing the number of possible values of the initial array that satisfy the conditions above, modulo .