結果

問題 No.1310 量子アニーリング
ユーザー 👑 H20H20
提出日時 2020-12-07 17:05:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 118,300 KB
最終ジャッジ日時 2023-10-17 16:32:49
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
104,900 KB
testcase_01 AC 84 ms
104,900 KB
testcase_02 AC 83 ms
104,900 KB
testcase_03 WA -
testcase_04 AC 83 ms
104,900 KB
testcase_05 AC 86 ms
104,900 KB
testcase_06 WA -
testcase_07 AC 83 ms
104,900 KB
testcase_08 AC 82 ms
104,900 KB
testcase_09 AC 82 ms
106,948 KB
testcase_10 WA -
testcase_11 AC 83 ms
107,160 KB
testcase_12 AC 90 ms
109,464 KB
testcase_13 AC 91 ms
112,368 KB
testcase_14 AC 93 ms
112,736 KB
testcase_15 WA -
testcase_16 AC 93 ms
113,120 KB
testcase_17 AC 99 ms
117,928 KB
testcase_18 WA -
testcase_19 AC 92 ms
112,888 KB
testcase_20 AC 89 ms
110,064 KB
testcase_21 AC 89 ms
109,808 KB
testcase_22 AC 101 ms
118,300 KB
testcase_23 AC 92 ms
112,384 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
# if N%4 == 0:
#     for i in range(N//4):
#         ans = (ans+(cmb(N,i*2,p)*2*po[N-i+1]))%p         
#     ans = (ans+cmb(N,N//2+1,p)*po[1])%p

if N % 2 ==0:
    for a,i in enumerate(range(N,-1,-4)):
        ans = (ans+(cmb(N,a*2,p)*4*po[i]))%p
else:
    for i in range(N//2+1):
        ans = (ans+(cmb(N,i,p)*2*po[N-(i*2)]))%p

print(ans)
0