結果

問題 No.1552 Simple Dice Game
ユーザー ygd.ygd.
提出日時 2021-06-18 21:52:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,144 ms / 2,500 ms
コード長 633 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 113,424 KB
最終ジャッジ日時 2023-09-04 22:51:56
合計ジャッジ時間 15,105 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,968 KB
testcase_01 AC 74 ms
71,200 KB
testcase_02 AC 75 ms
71,280 KB
testcase_03 AC 1,144 ms
113,304 KB
testcase_04 AC 76 ms
71,272 KB
testcase_05 AC 74 ms
71,244 KB
testcase_06 AC 74 ms
71,220 KB
testcase_07 AC 75 ms
71,428 KB
testcase_08 AC 74 ms
71,220 KB
testcase_09 AC 871 ms
105,220 KB
testcase_10 AC 1,009 ms
108,992 KB
testcase_11 AC 1,018 ms
109,208 KB
testcase_12 AC 339 ms
84,684 KB
testcase_13 AC 857 ms
105,184 KB
testcase_14 AC 535 ms
91,980 KB
testcase_15 AC 641 ms
96,520 KB
testcase_16 AC 155 ms
78,516 KB
testcase_17 AC 209 ms
79,576 KB
testcase_18 AC 829 ms
101,892 KB
testcase_19 AC 1,112 ms
113,168 KB
testcase_20 AC 1,116 ms
113,424 KB
testcase_21 AC 1,108 ms
113,272 KB
testcase_22 AC 1,107 ms
113,152 KB
testcase_23 AC 1,121 ms
113,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    mod = 998244353
    N,M = map(int,input().split())
    mx = 0
    pown = [0]
    for i in range(1,M+1):
        temp = pow(i,N-1,mod)
        pown.append(temp)


    for i in range(1,M+1): #1-M
        #temp = (i*(i+1)//2)*pow(i,N-1,mod)*N - ((i-1)*i//2)*pow(i-1,N-1,mod)*N
        temp = (i*(i+1)//2)*pown[i]*N - ((i-1)*i//2)*pown[i-1]*N
        mx += temp*i
        mx %= mod
    mn = 0
    for i in range(1,M+1):
        temp = ((M+i)*(M-i+1)//2)*pown[M-i+1]*N - ((M+i+1)*(M-i)//2)*pown[M-i]*N
        mn += temp*i
        mn %= mod
    
    ans = mx - mn
    print(ans%mod)


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