문제
Bessie knows a number where is some integer between to inclusive ().
Elsie is trying to guess this number. She can ask questions of the form "is high or low?" for some integer between and inclusive. Bessie responds by saying "HI!" if is greater than , or "LO!" if is less than .
Elsie comes up with the following strategy for guessing Bessie's number. Before making any guesses, she creates a list of numbers, where every number from to occurs exactly once (in other words, the list is a permutation of size .) 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 and Elsie previously guessed some such that Bessie responded with "HI!," Elsie will not guess and will move on to the next number in the list. Similarly, if she is about to guess some number and she previously guessed some such that Bessie responded with "LO!," Elsie will not guess and will move on to the next number in the list. It can be proven that using this strategy, Elsie always uniquely determines regardless of the permutation she creates.
If we concatenate all of Bessie's responses of either "HI" or "LO" into a single string the number of times Bessie says "HILO" is the number of length substrings of that are equal to "HILO."
Bessie knows that Elsie will use this strategy and has already chosen the value of , 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 .
입력
The only line of input contains and .
출력
The total number of HILOs modulo .
예제 입력 1
4 2
예제 출력 1
17
예제 입력 2
60 10
예제 출력 2
508859913
점수
Test cases 3-10 satisfy .Test cases 11-18 satisfy .Test cases 19-26 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인