結果

問題 No.2391 SAN 値チェック
ユーザー lam6er
提出日時 2025-04-09 20:58:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,740 KB
実行使用メモリ 79,768 KB
最終ジャッジ日時 2025-04-09 21:00:42
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def main():
    import sys
    input = sys.stdin.read
    N = int(input().strip())
    
    max_fact = N
    fact = [1] * (max_fact + 1)
    for i in range(1, max_fact + 1):
        fact[i] = fact[i-1] * i % MOD
    
    inv_fact = [1] * (max_fact + 1)
    inv_fact[max_fact] = pow(fact[max_fact], MOD-2, MOD)
    for i in range(max_fact - 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:
            t = N - i
            if t < 0:
                print(0)
            else:
                if t % 2 == 0:
                    res = inv_fact[t]
                else:
                    res = (MOD - inv_fact[t]) % MOD
                print(res)

if __name__ == "__main__":
    main()
0