PivotOJ

HILO

시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2021 December PlatinumBOJ 23871

문제

Bessie knows a number x+0.5x+0.5 where xx is some integer between 00 to N,N, inclusive (1N50001\le N\le 5000).

Elsie is trying to guess this number. She can ask questions of the form "is ii high or low?" for some integer ii between 11 and N,N, inclusive. Bessie responds by saying "HI!" if ii is greater than x+0.5x+0.5, or "LO!" if ii is less than x+0.5x+0.5.

Elsie comes up with the following strategy for guessing Bessie's number. Before making any guesses, she creates a list of NN numbers, where every number from 11 to NN occurs exactly once (in other words, the list is a permutation of size NN.) Then, she goes through the list, guessing numbers that appear in the list in order. However, Elsie skips any unnecessary guesses. That is, if Elsie is about to guess some number ii and Elsie previously guessed some j<ij < i such that Bessie responded with "HI!," Elsie will not guess ii and will move on to the next number in the list. Similarly, if she is about to guess some number ii and she previously guessed some j>ij > i such that Bessie responded with "LO!," Elsie will not guess ii and will move on to the next number in the list. It can be proven that using this strategy, Elsie always uniquely determines xx regardless of the permutation she creates.

If we concatenate all of Bessie's responses of either "HI" or "LO" into a single string S,S, the number of times Bessie says "HILO" is the number of length 44 substrings of SS that are equal to "HILO."

Bessie knows that Elsie will use this strategy and has already chosen the value of xx, but she does not know what permutation Elsie will use. Your goal is to compute the sum of the number of times Bessie says "HILO" over all permutations that Elsie could possibly choose, modulo 109+710^9+7.

입력

The only line of input contains NN and xx.

출력

The total number of HILOs modulo 109+710^9+7.

예제

예제 1

입력
4 2
출력
17

예제 2

입력
60 10
출력
508859913
코드를 제출하려면 로그인하세요.