結果

問題 No.1310 量子アニーリング
ユーザー 👑 H20H20
提出日時 2020-12-07 20:22:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 121,372 KB
最終ジャッジ日時 2023-10-17 16:38:42
合計ジャッジ時間 3,497 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
104,916 KB
testcase_01 AC 81 ms
104,916 KB
testcase_02 AC 82 ms
104,916 KB
testcase_03 AC 83 ms
104,916 KB
testcase_04 AC 82 ms
104,916 KB
testcase_05 AC 82 ms
104,916 KB
testcase_06 AC 81 ms
104,916 KB
testcase_07 AC 81 ms
104,916 KB
testcase_08 AC 81 ms
104,916 KB
testcase_09 AC 82 ms
104,916 KB
testcase_10 AC 82 ms
106,964 KB
testcase_11 AC 85 ms
107,176 KB
testcase_12 AC 92 ms
111,580 KB
testcase_13 AC 97 ms
115,340 KB
testcase_14 AC 99 ms
116,076 KB
testcase_15 AC 100 ms
118,748 KB
testcase_16 AC 103 ms
118,892 KB
testcase_17 AC 104 ms
121,372 KB
testcase_18 AC 104 ms
118,352 KB
testcase_19 AC 98 ms
118,428 KB
testcase_20 AC 95 ms
112,780 KB
testcase_21 AC 94 ms
112,272 KB
testcase_22 AC 106 ms
118,352 KB
testcase_23 AC 95 ms
115,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

p = 998244353
PN = 2  * 10 ** 5 + 100 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


for i in range(2, PN + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


po = [0]*(PN)
po[0] = 1
for i in range(1,N+2):
    po[i] = po[i-1]*2%p

ans = 0
for i in range(0,N+1,2):
    ans = (ans+(cmb(N,i,p)*2*po[abs(N-(i*2))]))%p
print(ans)
0