Under construction

Still being built. Things may change

Maxima

Time limit2sMemory limit1024 MB

Summary
Count permutations of 1 to n with exactly k maxima, where n is up to 10^15 and the answer is taken modulo 239.
Level

Hard8 of 10

Topics
Combinatorics, Matrix, Dynamic programming
Solved
No attempts yet

Problem

A permutation ⟨a_1,a_2,…,a_n⟩\langle a\_1, a\_2, \ldots, a\_n\rangle of the integers from 1 to nn is said to have kk maxima if the inequality a_i−1<a_i>a_i+1a\_{i-1} < a\_i > a\_{i+1} holds for exactly kk positions ii. Here a_0=a_n+1=0a\_0 = a\_{n+1} = 0.

For example, the permutation ⟨3,1,4,5,2⟩\langle 3, 1, 4, 5, 2 \rangle has two maxima: i=1i = 1 and i=4i = 4.

Input

The input file contains two integers nn and kk (1≤n≤10151 \le n \le 10^{15}, 1≤k≤301 \le k \le 30).

Output

Print one integer: the number of permutations of the integers from 1 to nn with exactly kk maxima, taken modulo 239.

Examples2

  1. Example 1

    Input
    3 1
    
    Expected output
    4
    
  2. Example 2

    Input
    10 3
    
    Expected output
    131