結果
問題 |
No.1552 Simple Dice Game
|
ユーザー |
![]() |
提出日時 | 2021-06-18 21:52:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 971 ms / 2,500 ms |
コード長 | 633 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 112,500 KB |
最終ジャッジ日時 | 2024-06-22 20:16:40 |
合計ジャッジ時間 | 12,244 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
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()