結果

問題 No.1310 量子アニーリング
ユーザー kk
提出日時 2020-12-23 11:28:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 204,348 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-10-21 15:06:47
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
6,752 KB
testcase_01 AC 30 ms
6,752 KB
testcase_02 AC 30 ms
6,752 KB
testcase_03 AC 31 ms
6,752 KB
testcase_04 AC 32 ms
6,752 KB
testcase_05 AC 31 ms
6,752 KB
testcase_06 AC 31 ms
6,752 KB
testcase_07 AC 31 ms
6,752 KB
testcase_08 AC 31 ms
6,756 KB
testcase_09 AC 30 ms
6,756 KB
testcase_10 AC 30 ms
6,760 KB
testcase_11 AC 30 ms
6,764 KB
testcase_12 AC 30 ms
6,804 KB
testcase_13 AC 30 ms
6,836 KB
testcase_14 AC 31 ms
6,836 KB
testcase_15 AC 37 ms
7,100 KB
testcase_16 AC 37 ms
7,100 KB
testcase_17 AC 38 ms
7,628 KB
testcase_18 AC 40 ms
7,892 KB
testcase_19 AC 37 ms
7,100 KB
testcase_20 AC 33 ms
6,752 KB
testcase_21 AC 30 ms
6,752 KB
testcase_22 AC 33 ms
7,892 KB
testcase_23 AC 30 ms
6,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const long long MOD = 998244353;

long long f[200000+1];
long long g[200000+1];

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

long long comb(long long n, long long k) {
  return f[n] * g[n-k] % MOD * g[k] % MOD;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  f[0] = g[0] = 1;
  for (int i = 1; i <= 200000; i++) {
    f[i] = i * f[i-1] % MOD;
    g[i] = modpow(f[i], MOD-2, MOD);
  }
  
  int n;
  cin >> n;

  vector<long long> t(n+1);
  t[0] = 1;
  for (int i = 1; i <= n; i++)
    t[i] = 2 * t[i-1] % MOD;

  long long ret = 0;
  for (int i = 0; i <= n; i += 2) {
    int e = n - 2 * i;
    long long pat = 2 * comb(n, i) % MOD;
    ret += pat * t[abs(e)] % MOD;
    ret %= MOD;
  }
  cout << ret << endl;
  
  return 0;
}
0