Problem:
Score : 900 points

Problem Statement

Snuke loves permutations. He is making a permutation of length N.

Since he hates the integer K, his permutation will satisfy the following:

Let the permutation be a_1, a_2, ..., a_N. For each i = 1,2,...,N, |a_i - i| \neq K.

Among the N! permutations of length N, how many satisfies this condition?

Since the answer may be extremely large, find the answer modulo 924844033(prime).

Constraints

2 ≦ N ≦ 2000

1 ≦ K ≦ N-1

Input

The input is given from Standard Input in the following format:

N K

Output

Print the answer modulo 924844033.

Sample Input 1

3 1

Sample Output 1

2

2 permutations (1, 2, 3), (3, 2, 1) satisfy the condition.

Sample Input 2

4 1

Sample Output 2

5

5 permutations (1, 2, 3, 4), (1, 4, 3, 2), (3, 2, 1, 4), (3, 4, 1, 2), (4, 2, 3, 1) satisfy the condition.

Sample Input 3

4 2

Sample Output 3

9

Sample Input 4

4 3

Sample Output 4

14

Sample Input 5

425 48

Sample Output 5

756765083

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const long long mod = 924844033;

int N, K;
vector<int> A[2020], B[2020]; bool chk[2020][2020];
long long fact[2020], prv[2020], nxt[2020], P[4020][2], Q[4020][2];

int main()
{
	scanf("%d %d", &N, &K);
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++){
		if (abs(i-j) == K){
			A[i].push_back(j);
			B[j].push_back(i);
			chk[i][j] = 1;
		}
	}

	prv[0] = 1;
	int deg = 0;
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) if (chk[i][j]){
		queue<pair<int, int> > que;
		que.push({ i,j }); chk[i][j] = 0;
		int L = 0;
		while (!que.empty()){
			auto p = que.front(); que.pop(); L++;
			for (int y : A[p.first]){
				int x = p.first;
				if (chk[x][y]){
					que.push({ x,y }); chk[x][y] = 0;
				}
			}
			for (int x : B[p.second]){
				int y = p.second;
				if (chk[x][y]){
					que.push({ x,y }); chk[x][y] = 0;
				}
			}
		}

		P[0][0] = 1;
		P[0][1] = 0;
		for (int k=1;k<=L;k++){
			for (int i=0;i<=k;i++) Q[i][0] = Q[i][1] = 0;
			for (int i=0;i<k;i++){
				Q[i][0] = (Q[i][0] + P[i][0] + P[i][1]) % mod;
				Q[i+1][1] = (Q[i+1][1] + P[i][0]) % mod;
			}
			for (int i=0;i<=k;i++) P[i][0] = Q[i][0], P[i][1] = Q[i][1];
		}

		for (int j=0;j<=deg+L;j++) nxt[j] = 0;
		for (int i=0;i<=deg;i++){
			for (int j=L;j>=0;j--){
				nxt[i+j] = (nxt[i+j] + prv[i] * (P[j][0] + P[j][1])) % mod;
			}
		}
		for (int j=0;j<=deg+L;j++) prv[j] = nxt[j];
		deg += L;
		while (deg > 0 && prv[deg] == 0) deg--;
	}

	fact[0] = 1;
	for (int i=1;i<=N;i++) fact[i] = fact[i-1] * i % mod;

	long long ans = 0, s = 1;
	for (int i=0;i<=N;i++){
		ans = (ans + fact[N-i] * prv[i] % mod * s + mod) % mod;
		s *= -1;
	}

	printf("%lld\n", ans);

	return 0;
}