結果

問題 No.1552 Simple Dice Game
ユーザー Kiri8128
提出日時 2021-06-18 21:58:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 370 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-06-22 20:21:26
合計ジャッジ時間 39,971 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other AC * 13 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353
N, M = map(int, input().split())
ans = 0
s = 0
for i in range(1, M + 1):
    ans += i * i * (i + 1) // 2 * pow(i, N - 1, P)
    s += M - i + 1
    ans -= s * (M - i + 1) * pow(i, N - 1, P)
    if i < M:
        ans -= i * (i + 1) * (i + 1) // 2 * pow(i, N - 1, P)
        ans += s * (M - i + 0) * pow(i, N - 1, P)
    ans %= P

ans *= N
ans %= P
print(ans)
0