結果

問題 No.1552 Simple Dice Game
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-06-18 22:06:27
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,747 ms / 2,500 ms
コード長 335 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 77,584 KB
最終ジャッジ日時 2023-09-04 23:11:26
合計ジャッジ時間 21,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 73 ms
71,124 KB
testcase_02 AC 72 ms
71,492 KB
testcase_03 AC 1,747 ms
76,952 KB
testcase_04 AC 70 ms
71,120 KB
testcase_05 AC 70 ms
71,228 KB
testcase_06 AC 69 ms
71,308 KB
testcase_07 AC 72 ms
71,356 KB
testcase_08 AC 72 ms
71,308 KB
testcase_09 AC 1,270 ms
77,040 KB
testcase_10 AC 1,493 ms
77,080 KB
testcase_11 AC 1,517 ms
77,092 KB
testcase_12 AC 492 ms
76,920 KB
testcase_13 AC 1,246 ms
76,984 KB
testcase_14 AC 774 ms
77,584 KB
testcase_15 AC 915 ms
76,676 KB
testcase_16 AC 197 ms
76,928 KB
testcase_17 AC 285 ms
77,280 KB
testcase_18 AC 1,222 ms
76,940 KB
testcase_19 AC 1,666 ms
76,992 KB
testcase_20 AC 1,697 ms
76,964 KB
testcase_21 AC 1,662 ms
77,032 KB
testcase_22 AC 1,670 ms
76,780 KB
testcase_23 AC 1,697 ms
76,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
mod = 998244353
ans = 0
bef = 0
for i in range(1,m+1):
    all = i*(i+1)//2*pow(i,n-1,mod)*n%mod
    ans += i*(all-bef)
    ans %= mod
    bef = all
bef = 0
for i in range(m,0,-1):
    all = (m*(m+1)//2-i*(i-1)//2)*pow(m+1-i,n-1,mod)*n%mod
    ans -= i*(all-bef)
    ans %= mod
    bef = all  
print(ans)
0