結果

問題 No.1310 量子アニーリング
ユーザー 👑 H20H20
提出日時 2020-12-07 19:52:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 121,584 KB
最終ジャッジ日時 2023-10-17 16:38:05
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
107,048 KB
testcase_01 AC 85 ms
107,048 KB
testcase_02 AC 84 ms
107,048 KB
testcase_03 WA -
testcase_04 AC 83 ms
107,048 KB
testcase_05 AC 82 ms
107,048 KB
testcase_06 WA -
testcase_07 AC 83 ms
107,048 KB
testcase_08 AC 83 ms
107,048 KB
testcase_09 AC 86 ms
107,048 KB
testcase_10 WA -
testcase_11 AC 87 ms
107,264 KB
testcase_12 AC 90 ms
109,600 KB
testcase_13 AC 92 ms
112,504 KB
testcase_14 AC 95 ms
112,872 KB
testcase_15 WA -
testcase_16 AC 94 ms
113,256 KB
testcase_17 AC 98 ms
118,064 KB
testcase_18 WA -
testcase_19 AC 92 ms
113,024 KB
testcase_20 AC 91 ms
110,200 KB
testcase_21 AC 88 ms
109,944 KB
testcase_22 AC 102 ms
118,420 KB
testcase_23 AC 92 ms
112,520 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:
    cnt = 0
    for i in range(N//4):
        ans = (ans+(cmb(N,i*2,p)*4*po[N-i]))%p
        cnt = (cnt + cmb(N,i*2,p)*4)%p
    ans = (ans+(po[N] - cnt)%p)%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