結果

問題 No.2391 SAN 値チェック
ユーザー qwewe
提出日時 2025-04-24 12:26:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 83,420 KB
最終ジャッジ日時 2025-04-24 12:26:41
合計ジャッジ時間 2,678 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
max_n = 2 * 10**5 + 10

# Precompute factorials and inverse factorials modulo MOD
fact = [1] * max_n
for i in range(1, max_n):
    fact[i] = fact[i-1] * i % MOD

inv_fact = [1] * max_n
inv_fact[max_n - 1] = pow(fact[max_n - 1], MOD - 2, MOD)
for i in range(max_n - 2, -1, -1):
    inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD

N = int(input())
a = [0] * (N + 1)

for m in range(N):
    sign = 1 if m % 2 == 0 else MOD - 1
    # Compute combination C(N-1, m)
    if m > N - 1:
        C = 0
    else:
        C = fact[N - 1] * inv_fact[m] % MOD
        C = C * inv_fact[N - 1 - m] % MOD
    term = sign * C % MOD
    term = term * inv_fact[m] % MOD
    i = N - m
    a[i] = term

for ai in a:
    print(ai % MOD)
0