結果

問題 No.1552 Simple Dice Game
ユーザー ygd.ygd.
提出日時 2021-06-18 21:48:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 494 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 76,864 KB
最終ジャッジ日時 2023-09-04 22:45:48
合計ジャッジ時間 39,803 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,072 KB
testcase_01 AC 73 ms
71,244 KB
testcase_02 AC 72 ms
71,440 KB
testcase_03 TLE -
testcase_04 AC 74 ms
71,260 KB
testcase_05 AC 73 ms
71,472 KB
testcase_06 AC 73 ms
71,176 KB
testcase_07 AC 73 ms
71,500 KB
testcase_08 AC 75 ms
71,472 KB
testcase_09 AC 2,433 ms
76,864 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 901 ms
76,128 KB
testcase_13 AC 2,395 ms
76,720 KB
testcase_14 AC 1,470 ms
76,672 KB
testcase_15 AC 1,741 ms
76,804 KB
testcase_16 AC 308 ms
76,508 KB
testcase_17 AC 480 ms
76,584 KB
testcase_18 AC 2,356 ms
76,416 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def main():
    mod = 998244353
    N,M = map(int,input().split())
    mx = 0
    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
        mx += temp*i
        mx %= mod
    mn = 0
    for i in range(1,M+1):
        temp = ((M+i)*(M-i+1)//2)*pow(M-i+1,N-1,mod)*N - ((M+i+1)*(M-i)//2)*pow(M-i,N-1,mod)*N
        mn += temp*i
        mn %= mod
    
    ans = mx - mn
    print(ans%mod)


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