結果

問題 No.1552 Simple Dice Game
ユーザー tassei903tassei903
提出日時 2021-06-18 23:11:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,119 ms / 2,500 ms
コード長 610 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 81,276 KB
最終ジャッジ日時 2023-09-05 00:08:41
合計ジャッジ時間 15,065 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,208 KB
testcase_01 AC 73 ms
71,096 KB
testcase_02 AC 77 ms
71,400 KB
testcase_03 AC 1,019 ms
81,276 KB
testcase_04 AC 71 ms
71,356 KB
testcase_05 AC 71 ms
71,356 KB
testcase_06 AC 70 ms
71,420 KB
testcase_07 AC 72 ms
71,464 KB
testcase_08 AC 73 ms
71,316 KB
testcase_09 AC 868 ms
80,216 KB
testcase_10 AC 972 ms
80,652 KB
testcase_11 AC 1,010 ms
80,864 KB
testcase_12 AC 357 ms
77,968 KB
testcase_13 AC 851 ms
80,300 KB
testcase_14 AC 537 ms
78,908 KB
testcase_15 AC 632 ms
79,228 KB
testcase_16 AC 167 ms
77,080 KB
testcase_17 AC 216 ms
77,360 KB
testcase_18 AC 807 ms
79,856 KB
testcase_19 AC 1,083 ms
80,820 KB
testcase_20 AC 1,103 ms
80,828 KB
testcase_21 AC 1,100 ms
80,884 KB
testcase_22 AC 1,096 ms
80,820 KB
testcase_23 AC 1,119 ms
81,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")

n,m = na()
mod = 998244353
z = [pow(i,n,mod) for i in range(m+1)]
d2 = pow(2,mod-2,mod)
def g(x):
    return ((z[x]*(x+1)*d2)%mod)*n%mod

def h(x):
    return ((z[m-x+1]*(m+x)*d2)%mod)*n%mod
ans = 0
for k in range(1,m+1):
    #print(g(k)-g(k-1),h(k)-h(k+1))
    ans+=k*(g(k)-g(k-1))%mod
    ans%=mod
    ans-=k*(h(k)-h(k+1))%mod
    ans%=mod
print(ans)
0