CF1436C.Binary Search

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number xx in an array. For an array aa indexed from zero, and an integer xx the pseudocode of the algorithm is as follows:

Note that the elements of the array are indexed from zero, and the division is done in integers (rounding down).

Andrey read that the algorithm only works if the array is sorted. However, he found this statement untrue, because there certainly exist unsorted arrays for which the algorithm find xx !

Andrey wants to write a letter to the book authors, but before doing that he must consider the permutations of size nn such that the algorithm finds xx in them. A permutation of size nn is an array consisting of nn distinct integers between 11 and nn in arbitrary order.

Help Andrey and find the number of permutations of size nn which contain xx at position pospos and for which the given implementation of the binary search algorithm finds xx (returns true). As the result may be extremely large, print the remainder of its division by 109+710^9+7 .

输入格式

The only line of input contains integers nn , xx and pospos ( 1xn10001 \le x \le n \le 1000 , 0posn10 \le pos \le n - 1 ) — the required length of the permutation, the number to search, and the required position of that number, respectively.

输出格式

Print a single number — the remainder of the division of the number of valid permutations by 109+710^9+7 .

输入输出样例

  • 输入#1

    4 1 2

    输出#1

    6
  • 输入#2

    123 42 24

    输出#2

    824071958

说明/提示

All possible permutations in the first test case: (2,3,1,4)(2, 3, 1, 4) , (2,4,1,3)(2, 4, 1, 3) , (3,2,1,4)(3, 2, 1, 4) , (3,4,1,2)(3, 4, 1, 2) , (4,2,1,3)(4, 2, 1, 3) , (4,3,1,2)(4, 3, 1, 2) .

首页