Under construction

Still being built. Things may change

Permutations and Increasing Sequences

Time limit2sMemory limit1024 MB

Summary
Count permutations of 1 to N whose length-K window sums strictly increase, printed modulo 1e9+7.
Level

Medium4 of 10

Topics
Math, Combinatorics, Array
Solved
No attempts yet

문제

Geondeok, who liked playing with permutations, found a beautiful property in a sequence he built. His permutation AA satisfies two conditions. First, AA contains every integer from 1 to NN exactly once. Second, the sequence BB formed by adding KK consecutive terms of AA is an increasing sequence. That is, Bi=Ai+Ai+1+⋯+Ai+K−1B_i = A_i + A_{i+1} + \cdots + A_{i+K-1} for 1≤i≤N−K+11 \le i \le N-K+1.

For example, if A={1,3,2,5,4}A = \{1, 3, 2, 5, 4\} and K=3K = 3, then B={6,10,11}B = \{6, 10, 11\}, so both conditions hold.

Geondeok wants to know how many permutations AA have this property. Help him count, for given NN and KK, the permutations of length NN that satisfy both conditions.

입력

The first line contains two integers NN and KK, separated by a space. (1≤K≤N≤1,000,000)(1 \le K \le N \le 1,000,000)

출력

Print the number of permutations of length NN that satisfy the property, modulo 109+710^9+7.

Examples1

  1. Example 1

    Input
    4 3
    
    Expected output
    12