結果

問題 No.1310 量子アニーリング
ユーザー trineutrontrineutron
提出日時 2020-12-07 00:22:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 90,684 KB
最終ジャッジ日時 2023-10-17 15:44:19
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,468 KB
testcase_01 AC 38 ms
53,468 KB
testcase_02 AC 36 ms
53,468 KB
testcase_03 AC 35 ms
53,468 KB
testcase_04 AC 36 ms
53,468 KB
testcase_05 AC 36 ms
53,468 KB
testcase_06 AC 37 ms
53,468 KB
testcase_07 AC 35 ms
53,468 KB
testcase_08 AC 36 ms
53,468 KB
testcase_09 AC 36 ms
53,468 KB
testcase_10 AC 38 ms
53,468 KB
testcase_11 AC 40 ms
59,660 KB
testcase_12 AC 45 ms
64,312 KB
testcase_13 AC 63 ms
72,644 KB
testcase_14 AC 69 ms
76,980 KB
testcase_15 AC 79 ms
81,036 KB
testcase_16 AC 78 ms
81,180 KB
testcase_17 AC 100 ms
88,044 KB
testcase_18 AC 113 ms
90,684 KB
testcase_19 AC 76 ms
77,936 KB
testcase_20 AC 59 ms
69,000 KB
testcase_21 AC 52 ms
67,356 KB
testcase_22 AC 112 ms
90,420 KB
testcase_23 AC 62 ms
72,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

n = int(input())

fact = [1]
for i in range(n):
    fact.append(fact[i] * (i + 1) % mod)
inv = [0] * (n + 1)
inv[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    inv[i] = inv[i + 1] * (i + 1) % mod

def ncr(n, r):
    return fact[n] * inv[r] * inv[n - r] % mod

ans = 0
for i in range(0, n + 1, 2):
    ans += ncr(n, i) * pow(2, abs(n - 2 * i), mod)
ans *= 2
print(ans % mod)
0