結果

問題 No.1552 Simple Dice Game
ユーザー shotoyooshotoyoo
提出日時 2021-06-18 23:08:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,651 ms / 2,500 ms
コード長 702 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2023-09-05 00:07:43
合計ジャッジ時間 20,909 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,140 KB
testcase_01 AC 71 ms
71,364 KB
testcase_02 AC 70 ms
71,596 KB
testcase_03 AC 1,432 ms
77,132 KB
testcase_04 AC 74 ms
71,400 KB
testcase_05 AC 75 ms
71,552 KB
testcase_06 AC 71 ms
71,300 KB
testcase_07 AC 73 ms
71,404 KB
testcase_08 AC 74 ms
71,256 KB
testcase_09 AC 1,256 ms
76,752 KB
testcase_10 AC 1,409 ms
77,356 KB
testcase_11 AC 1,470 ms
77,340 KB
testcase_12 AC 492 ms
77,036 KB
testcase_13 AC 1,229 ms
77,156 KB
testcase_14 AC 768 ms
76,944 KB
testcase_15 AC 904 ms
76,944 KB
testcase_16 AC 203 ms
77,180 KB
testcase_17 AC 287 ms
77,376 KB
testcase_18 AC 1,166 ms
77,028 KB
testcase_19 AC 1,625 ms
77,188 KB
testcase_20 AC 1,634 ms
76,888 KB
testcase_21 AC 1,633 ms
76,860 KB
testcase_22 AC 1,625 ms
77,172 KB
testcase_23 AC 1,651 ms
77,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
M = 998244353
ans = 0
inv2 = pow(2, M-2, M)
def f(v):
    return inv2 * (n * ((v+1) * pow(v, n, M) % M) % M) % M
def g(v):
    return inv2 * ((m + v) * (n * pow(m-v+1, n, M) % M) % M) % M
# for v in range(1,m+1):
#     ans += v * (f(v) - f(v-1)) % M
#     ans -= v * (g(v) - g(v+1)) % M
#     ans %= M
ans = m*f(m) - g(1)
for v in range(2, m+1):
    ans -= g(v)
    ans %= M
for v in range(1,m):
    ans -= f(v)
    ans %= M
print(ans%M)
0