Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

const int MOD = 924844033;

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 1 << 11
const Modint inv2 = inv(Modint(2));

Modint dp [MAX_N / 2][MAX_N / 2][3]; // position, # of things, is last taken

vector<Modint> do_dp (int n, int ls, int rs) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= 2; k++) {
        dp[i][j][k] = Modint(0);
      }
    }
  }

  if (n == -1) {
    vector<Modint> ans (2);
    ans[0] = Modint(1);
    ans[1] = Modint(0);
    return ans;
  }
  
  if (n == 1 && (ls == 1 || rs == 1)) {
    vector<Modint> ans (2, Modint(1));
    return ans;
  }
  
  if (ls) {
    dp[1][0][0] = Modint(1);
    dp[1][1][2] = Modint(1);
  } else {
    dp[1][0][0] = Modint(1);
    dp[1][1][1] = Modint(1);
    dp[1][1][2] = Modint(1);
  }
  
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][j][0] += dp[i][j][0];
      dp[i + 1][j + 1][1] += dp[i][j][0];
      dp[i + 1][j + 1][2] += dp[i][j][0];

      dp[i + 1][j][0] += dp[i][j][1];
      dp[i + 1][j + 1][1] += dp[i][j][1];
      dp[i + 1][j + 1][2] += dp[i][j][1];

      dp[i + 1][j][0] += dp[i][j][2];
      dp[i + 1][j + 1][2] += dp[i][j][2];
    }
  }
  
  vector<Modint> ans (n + 1);
  for (int i = 0; i <= n; i++) {
    ans[i] = dp[n][i][0] + dp[n][i][1];
    if (!rs) {
      ans[i] += dp[n][i][2];
    }
  }
  return ans;
}

typedef pair<int, pair<int, int>> type;

type get_type (int u, int n, int k) {
  if (u - k <= 0 && u + k > n) return make_pair(-1, make_pair(0, 0));
  
  int fst = u;
  int len = 1;
  while (true) {
    if (u + 2 * k > n) break;
    u += 2 * k;
    len++;
  }
  int lst = u;

  int ls = 0;
  if (fst - k <= 0) ls = 1;
  int rs = 0;
  if (lst + k > n) rs = 1;
  return make_pair(len, make_pair(ls, rs));
}

vector<Modint> mul (vector<Modint> p, vector<Modint> q) {
  vector<Modint> ans ((int) p.size() + (int) q.size() - 1, Modint(0));
  for (int i = 0; i < (int) p.size(); i++) {
    for (int j = 0; j < (int) q.size(); j++) {
      ans[i + j] += p[i] * q[j];
    }
  }
  return ans;
}

vector<Modint> exp (vector<Modint> p, int k) {
  if (k == 0) {
    return vector<Modint> (1, Modint(1));
  } else if (k % 2 == 0) {
    auto half = exp(p, k / 2);
    return mul(half, half);
  } else {
    return mul(p, exp(p, k - 1));
  }
}

Modint fact [MAX_N];

int main () {
  fact[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = Modint(i) * fact[i - 1];
  }
  
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;

  map<type, int> cnt;
  for (int i = 1; i <= min(n, 2 * k); i++) {
    type cur = get_type(i, n, k);
    if (cnt.find(cur) == cnt.end()) {
      cnt[cur] = 0;
    }
    cnt[cur]++;
  }

  vector<Modint> ans (1, Modint(1));
  for (auto it = cnt.begin(); it != cnt.end(); it++) {
    vector<Modint> cur = do_dp(it->first.first, it->first.second.first, it->first.second.second);
    cur = exp(cur, it->second);
    ans = mul(ans, cur);
  }
  
  Modint sol (0);
  for (int i = 0; i <= n; i++) {
    Modint add = ans[i] * fact[n - i];
    if (i % 2 == 0) sol += add;
    else sol += Modint(MOD - 1) * add;
  }
  cout << sol << endl;
}


Compiler output:
a.cc:78:1: error: expected ',' or ';' before 'const'
   78 | const Modint inv2 = inv(Modint(2));
      | ^~~~~