結果

問題 No.1552 Simple Dice Game
ユーザー 👑 tamatotamato
提出日時 2021-06-18 21:47:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 843 ms / 2,500 ms
コード長 660 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 91,900 KB
最終ジャッジ日時 2023-09-04 22:43:03
合計ジャッジ時間 11,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,448 KB
testcase_01 AC 80 ms
71,344 KB
testcase_02 AC 76 ms
71,308 KB
testcase_03 AC 843 ms
91,660 KB
testcase_04 AC 76 ms
71,532 KB
testcase_05 AC 74 ms
71,524 KB
testcase_06 AC 76 ms
71,612 KB
testcase_07 AC 77 ms
71,672 KB
testcase_08 AC 78 ms
71,528 KB
testcase_09 AC 629 ms
88,896 KB
testcase_10 AC 730 ms
90,564 KB
testcase_11 AC 741 ms
90,572 KB
testcase_12 AC 279 ms
80,096 KB
testcase_13 AC 625 ms
88,264 KB
testcase_14 AC 409 ms
82,904 KB
testcase_15 AC 470 ms
84,896 KB
testcase_16 AC 139 ms
76,780 KB
testcase_17 AC 179 ms
77,864 KB
testcase_18 AC 617 ms
87,296 KB
testcase_19 AC 811 ms
91,612 KB
testcase_20 AC 820 ms
91,900 KB
testcase_21 AC 804 ms
91,760 KB
testcase_22 AC 803 ms
91,616 KB
testcase_23 AC 819 ms
91,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())

    ans = 0
    K = [0] * (M+1)
    L = [(M * (M+1) // 2)%mod] * (M+1)
    for i in range(1, M+1):
        K[i] = (K[i-1] + i)%mod
        L[i] = (L[i-1] - (i - 1))%mod
    L.append(0)
    P = [0] * (M+1)
    for i in range(M+1):
        P[i] = pow(i, N-1, mod)
    for i in range(1, M+1):
        ans = (ans + (i * ((K[i] * P[i])%mod - (K[i-1] * P[i-1])%mod)%mod)%mod)%mod
        ans = (ans - (i * ((L[i] * P[M-i+1])%mod - (L[i + 1] * P[M-i])%mod) % mod)%mod)% mod
    print((ans * N)%mod)


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