結果

問題 No.1310 量子アニーリング
ユーザー Ryushi-techRyushi-tech
提出日時 2020-12-13 00:21:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,151 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 202,216 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-10-20 02:49:26
合計ジャッジ時間 3,294 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,356 KB
testcase_01 AC 7 ms
8,356 KB
testcase_02 AC 7 ms
8,356 KB
testcase_03 AC 7 ms
8,356 KB
testcase_04 AC 7 ms
8,356 KB
testcase_05 AC 7 ms
8,356 KB
testcase_06 AC 7 ms
8,356 KB
testcase_07 AC 8 ms
8,356 KB
testcase_08 AC 8 ms
8,356 KB
testcase_09 AC 7 ms
8,356 KB
testcase_10 AC 8 ms
8,356 KB
testcase_11 AC 8 ms
8,356 KB
testcase_12 AC 8 ms
8,356 KB
testcase_13 AC 10 ms
8,356 KB
testcase_14 AC 11 ms
8,356 KB
testcase_15 AC 11 ms
8,356 KB
testcase_16 AC 12 ms
8,356 KB
testcase_17 AC 14 ms
8,356 KB
testcase_18 AC 16 ms
8,356 KB
testcase_19 AC 11 ms
8,356 KB
testcase_20 AC 9 ms
8,356 KB
testcase_21 AC 9 ms
8,356 KB
testcase_22 AC 16 ms
8,356 KB
testcase_23 AC 9 ms
8,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)

const int lim = 202020;
const ll mod = 998244353;

ll powmod(ll n, ll k){
    k %= mod - 1;
    if (k < 0) k += mod - 1;
    ll ret = 1;
    while (k) {
        if (k & 1) ret = ret * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

ll fac[lim], finv[lim], inv[lim];

void fac_build() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < lim; i++){
    fac[i] = fac[i - 1] * (ll)i % mod;
    inv[i] = mod - inv[mod % i] * (mod / (ll)i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

ll nCr(int n, int k){
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll nPr(int n, int k){
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % mod;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n; cin >> n;
  fac_build();
  ll ans = 0;
  for (int i = 0; i <= n; i+=2) {
    ans += 2 * powmod(2, abs(n - 2 * i)) * nCr(n, i) % mod;
    if (ans > mod) ans -= mod;
  }
  cout << ans << "\n";
}
0