結果

問題 No.1886 Sum of Slide Max
ユーザー 👑 rin204rin204
提出日時 2022-03-25 21:49:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 81,536 KB
最終ジャッジ日時 2024-04-22 06:29:34
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
62,592 KB
testcase_01 AC 50 ms
62,592 KB
testcase_02 AC 49 ms
62,464 KB
testcase_03 AC 51 ms
62,336 KB
testcase_04 AC 50 ms
62,208 KB
testcase_05 AC 86 ms
79,232 KB
testcase_06 AC 63 ms
69,120 KB
testcase_07 AC 86 ms
81,536 KB
testcase_08 AC 91 ms
79,232 KB
testcase_09 AC 88 ms
79,068 KB
testcase_10 AC 92 ms
79,480 KB
testcase_11 AC 87 ms
79,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
N = 200200
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i - 1] * i % MOD

invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)

for i in range(N - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD

def nCk(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fact[n] * invfact[k] % MOD) * invfact[n - k] % MOD

def nHk(n, k):
    return nCk(n + k - 1, k)
    
n = int(input())
for i in range(1, n + 1):
    ans = (fact[i + 1] - fact[i]) % MOD
    ans *= (n - i + 1) * fact[n + 1] % MOD
    ans %= MOD
    ans *= invfact[i + 1]
    print(ans % MOD)
0