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 C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToList();
        var N = input[0];
        var K = input[1];
        decimal[,,] dp = new decimal[55, 55, 2650];
        dp[0, 0, 0] = 1;
        for (int i = 0; i < N; ++i)
        {
            for (int j = 0; j < i + 1; ++j)
            {
                for (int k = 0; k < K + 1; ++k)
                {
                    {
                        int nj = j;
                        dp[i + 1, nj, k + nj * 2] += dp[i, j, k];
                    }
                    {
                        int nj = j + 1;
                        dp[i + 1, nj, k + nj * 2] += dp[i, j, k];
                    }
                    {
                        int nj = j;
                        int x = j * 2;
                        dp[i + 1, nj, k + nj * 2] += dp[i, j, k] * x;
                    }
                    if (j >= 1)
                    {
                        int nj = j - 1;
                        int x = j * j;
                        dp[i + 1, nj, k + nj * 2] += dp[i, j, k] * x;
                    }
                }
            }
        }
        var ans = dp[N, 0, K];
        if (K % 2 == 1) Console.WriteLine(0);
        else
        {
            Console.WriteLine(ans % 1000000007);
        }
    }
}