結果

問題 No.2237 Xor Sum Hoge
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-10-05 12:50:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,033 bytes
コンパイル時間 4,544 ms
コンパイル使用メモリ 263,804 KB
実行使用メモリ 8,492 KB
最終ジャッジ日時 2023-10-05 12:50:47
合計ジャッジ時間 27,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n");
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using mint = modint998244353;
using vm = vector<mint>;

template <typename mint>
class Factorial {
 public:
  Factorial(int max) : n(max) {
    f = vector<mint>(n + 1);
    finv = vector<mint>(n + 1);
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i;
    finv[n] = f[n].inv();
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * i;
  }
  mint fact(int k) {
    assert(0 <= k && k <= n);
    return f[k];
  }
  mint fact_inv(int k) {
    assert(0 <= k && k <= n);
    return finv[k];
  }
  mint binom(int k, int r) {
    assert(0 <= k && k <= n);
    if (r < 0 || r > k) return 0;
    return f[k] * finv[r] * finv[k - r];
  }
  mint inv(int k) {
    assert(0 < k && k <= n);
    return finv[k] * f[k - 1];
  }

 private:
  int n;
  vector<mint> f, finv;
};

int main() {
  const int LOG = 60;
  int n;
  ll b, c;
  cin >> n >> b >> c;
  Factorial<mint> fact(n);

  vm dp(n + 1, 0);
  dp[0] = 1;
  rrep(k, 0, LOG) {
    int bd = (int)((b >> k) & 1);
    int cd = (int)((c >> k) & 1);
    vm newdp(n + 1, 0);
    for (int i = bd ^ cd; i <= n; i += 2) {
      for (int j = cd; j <= n; j += 2) {
        newdp[i] += dp[(i + j + (bd ^ 1)) / 2] * fact.binom(n, j);
      }
    }
    dp = newdp;
  }
  cout << dp[0].val() << endl;
}
0