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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
int n, K;
const int C = 3000;
int dp[51][51][2 * C];	//dp[i][j][k + C] = (i, i)から見る. j個対応作った. 暫定奇妙さ = k (-C ≦ k < C)

signed main() {
	int i, j, k;
	
	cin >> n >> K;
	
	if (K >= C) { cout << 0 << endl; return 0; }
	
	dp[0][0][C] = 1;
	rep(i, n) {
		rep(j, i + 1) {
			rep(k, 2 * C) {
				if (dp[i][j][k] == 0) continue;

				if (k - 2 * i >= 0) {
					(dp[i + 1][j][k - 2 * i] += dp[i][j][k]) %= mod;
				}
				
				(dp[i + 1][j + 1][k] += 2 * (i - j) * dp[i][j][k]) %= mod;
				
				if (j + 2 <= i + 1) {
					(dp[i + 1][j + 2][k + 2 * i] += (i - j) * (i - j) * dp[i][j][k]) % mod;
				}
				
				(dp[i + 1][j + 1][k] += dp[i][j][k]) %= mod;
			}
		}
	}
	
	cout << dp[n][n][C + K] << endl;
	return 0;
}