Problem:
Score : 600 points

Problem Statement

Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.

Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Constraints

All values in input are integers.

1 \leq n \leq 50

0 \leq k \leq n^2

Input

Input is given from Standard Input in the following format:

n k

Output

Print the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Sample Input 1

3 2

Sample Output 1

2

There are six permutations of {1,\ 2,\ 3}. Among them, two have oddness of 2: {2,\ 1,\ 3} and {1,\ 3,\ 2}.

Sample Input 2

39 14

Sample Output 2

74764168

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,k:usize,
    }
    let mut dp = vec![vec![vec![0i128; 3333]; 55]; 55];
    dp[0][0][0] = 1;
    for i in 0..n {
        for rest in 0..n {
            for k in 0..=k {
                let ad = dp[i][rest][k];
                dp[i + 1][rest + 1][k + 2 * rest + 2] += ad;
                dp[i + 1][rest + 1][k + 2 * rest + 2] %= MOD;
                dp[i + 1][rest][k + 2 * rest] += ad;
                dp[i + 1][rest][k + 2 * rest] %= MOD;
                if rest > 0 {
                    dp[i + 1][rest - 1][k + 2 * rest - 2] += ad * (rest * rest) as i128;
                    dp[i + 1][rest - 1][k + 2 * rest - 2] %= MOD;
                    dp[i + 1][rest][k + 2 * rest] += ad * 2 * rest as i128;
                    dp[i + 1][rest][k + 2 * rest] %= MOD;
                }
                dp[i][rest][k] %= MOD;
            }
        }
    }
    println!("{}", dp[n][0][k] % MOD);
}
const MOD: i128 = 1000000007;