#P11500. Alternate Increase-Decrease Training Schedule

    ID: 13586 Type: Default 1000ms 256MiB

Alternate Increase-Decrease Training Schedule

Alternate Increase-Decrease Training Schedule

The Department of Sports has developed a new interval training method. According to this method, athletes train every day, but the training load must alternate between increasing and decreasing. A training plan is represented by a sequence of positive integers \(a_1, a_2, \dots, a_m\), where \(a_i\) is the load on day \(i\). It is required that any two consecutive days have different loads, i.e. \(a_i \neq a_{i+1}\). Moreover, to ensure the load alternates between increasing and decreasing, the sequence must satisfy:

  • If \(a_i a_{i+2}\).
  • If \(a_i > a_{i+1}\) then \(a_{i+1} < a_{i+2}\).

The overall training load is fixed to \(n\), i.e. \(\sum_{i=1}^{m}a_i = n\). The number of days \(m\) in the plan can be arbitrary (\(m \ge 1\)) but the load on the first day is fixed to \(a_1=k\). The management wants to know how many different training plans satisfy the above requirements. Since the answer can be very large, output the result modulo \(10^9+7\).

Note: For a plan with only one day (i.e. \(m=1\)), it is valid only when \(k=n\).

inputFormat

The input consists of two integers \(n\) and \(k\) (\(1 \le k \le n\)), separated by a space, where \(n\) is the total load and \(k\) is the load on the first day.

outputFormat

Output a single integer, the number of valid training plans modulo \(10^9+7\).

sample

6 2
3