結果

問題 No.2391 SAN 値チェック
ユーザー lam6er
提出日時 2025-04-16 00:46:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 81,060 KB
最終ジャッジ日時 2025-04-16 00:50:15
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

N = int(input())

if N == 0:
    print(0)
else:
    max_n = N
    fact = [1] * (max_n + 1)
    for i in range(1, max_n + 1):
        fact[i] = fact[i-1] * i % MOD

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

    for i in range(N + 1):
        if i == 0:
            print(0)
        else:
            power = (N - i) % 2
            sign = 1 if power == 0 else MOD - 1
            res = sign * fact[N-1] % MOD
            res = res * inv_fact[i-1] % MOD
            res = res * inv_fact[N - i] % MOD
            res = res * inv_fact[N - i] % MOD
            print(res)
0