結果

問題 No.1897 Sum of 2nd Max
ユーザー とりゐとりゐ
提出日時 2022-04-08 21:46:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 548 ms / 2,000 ms
コード長 314 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 72,448 KB
最終ジャッジ日時 2024-05-06 07:20:03
合計ジャッジ時間 8,321 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,840 KB
testcase_01 AC 35 ms
51,584 KB
testcase_02 AC 34 ms
51,968 KB
testcase_03 AC 457 ms
72,448 KB
testcase_04 AC 449 ms
69,376 KB
testcase_05 AC 238 ms
63,488 KB
testcase_06 AC 241 ms
62,080 KB
testcase_07 AC 314 ms
65,536 KB
testcase_08 AC 266 ms
63,872 KB
testcase_09 AC 450 ms
71,936 KB
testcase_10 AC 428 ms
71,808 KB
testcase_11 AC 430 ms
71,680 KB
testcase_12 AC 421 ms
71,936 KB
testcase_13 AC 426 ms
71,808 KB
testcase_14 AC 128 ms
60,032 KB
testcase_15 AC 134 ms
60,032 KB
testcase_16 AC 194 ms
60,928 KB
testcase_17 AC 162 ms
60,288 KB
testcase_18 AC 179 ms
60,672 KB
testcase_19 AC 37 ms
51,840 KB
testcase_20 AC 37 ms
51,584 KB
testcase_21 AC 35 ms
51,840 KB
testcase_22 AC 37 ms
51,712 KB
testcase_23 AC 38 ms
52,096 KB
testcase_24 AC 37 ms
51,968 KB
testcase_25 AC 35 ms
52,096 KB
testcase_26 AC 36 ms
52,096 KB
testcase_27 AC 36 ms
52,480 KB
testcase_28 AC 35 ms
51,712 KB
testcase_29 AC 36 ms
51,584 KB
testcase_30 AC 432 ms
72,064 KB
testcase_31 AC 467 ms
72,064 KB
testcase_32 AC 365 ms
65,792 KB
testcase_33 AC 548 ms
69,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
n,k=map(int,input().split())
ans=0
for x in range(1,k+1):
  ans+=x*(k-x)%mod*(pow(x,n-1,mod)-pow(x-1,n-1,mod))%mod*n
  ans%=mod
  #print(x*(k-x)%mod*(pow(x,n-1,mod)-pow(x-1,n-1,mod)))

for x in range(1,k+1):
  tmp=pow(x,n,mod)-n*pow(x-1,n-1,mod)-pow(x-1,n,mod)
  ans+=x*tmp%mod
  ans%=mod

print(ans)
0