Distance Permutation
시간 제한5초메모리 제한1024 MB
걷기 과정에서 만들어질 수 있는 1..N의 순열 가운데 첫 값이 [L, R]에 들어가는 순열의 개수를 센다.
문제
You construct a permutation of length in the following way.
The number line has points . The distance between points and is . Also, there is a sequence that is initially empty. Repeat the following operations from any point until the length of is .
- Let be the number corresponding to the current point. if is not in , add to the end of . Next, move to one of the points whose distance is less than or equal to .
Answer the following queries.
You are given integers , , . Let the sequence created by removing elements larger than from be . Among the possible permutations of , answer the number of permutations in which is greater than or equal to and less than or equal to with .
입력
represents the -th query.
Each query is given in the following format.
출력
Output lines. On the -th line, output the answer of the -th query.
제한
- All inputs consist of integers.
힌트
In Sample Input 1, There are four possible sequences as in the first query.