結果

問題 No.1552 Simple Dice Game
ユーザー tamatotamato
提出日時 2021-06-18 21:44:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 88,624 KB
最終ジャッジ日時 2023-09-04 22:39:49
合計ジャッジ時間 37,808 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,148 KB
testcase_01 AC 76 ms
71,276 KB
testcase_02 AC 72 ms
71,564 KB
testcase_03 TLE -
testcase_04 AC 77 ms
71,364 KB
testcase_05 AC 77 ms
71,520 KB
testcase_06 AC 75 ms
71,624 KB
testcase_07 AC 75 ms
71,528 KB
testcase_08 AC 77 ms
71,508 KB
testcase_09 AC 2,328 ms
85,804 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 881 ms
78,788 KB
testcase_13 AC 2,292 ms
85,300 KB
testcase_14 AC 1,404 ms
81,512 KB
testcase_15 AC 1,658 ms
82,928 KB
testcase_16 AC 302 ms
77,616 KB
testcase_17 AC 471 ms
77,624 KB
testcase_18 AC 2,260 ms
84,620 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

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)
    for i in range(1, M+1):
        ans = (ans + (i * ((K[i] * pow(i, N-1, mod) * N)%mod - (K[i-1] * pow(i-1, N-1, mod) * N)%mod)%mod)%mod)%mod
        ans = (ans - (i * ((L[i] * pow(M - i + 1, N - 1, mod) * N)%mod - (L[i + 1] * pow(M - i, N - 1, mod) * N)%mod) % mod)%mod)% mod
    print(ans)


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