結果

問題 No.1310 量子アニーリング
ユーザー rlangevinrlangevin
提出日時 2023-02-12 19:48:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 592 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 83,380 KB
最終ジャッジ日時 2023-09-23 06:46:18
合計ジャッジ時間 4,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
79,192 KB
testcase_01 AC 85 ms
79,172 KB
testcase_02 AC 85 ms
79,220 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 84 ms
79,164 KB
testcase_06 WA -
testcase_07 AC 84 ms
79,228 KB
testcase_08 AC 84 ms
79,172 KB
testcase_09 AC 84 ms
79,344 KB
testcase_10 WA -
testcase_11 AC 89 ms
79,492 KB
testcase_12 AC 103 ms
79,764 KB
testcase_13 AC 128 ms
81,876 KB
testcase_14 AC 142 ms
82,256 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 179 ms
83,284 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 119 ms
81,008 KB
testcase_21 AC 111 ms
80,296 KB
testcase_22 AC 201 ms
80,144 KB
testcase_23 AC 128 ms
81,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

n = 202020
mod = 998244353

fact = [1] * (n + 1)
inv = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
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 comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * inv[r] * inv[n - r] % mod

ans = 0
for i in range(N):
    if i % 2:
        ans += 2 * comb(N - 1, i) * pow(2, abs(N - 2 * i), mod)
    else:
        ans += 2 * comb(N - 1, i) * pow(2, abs(N - 2 * i - 2), mod)
    ans %= mod
print(ans)        
0