結果

問題 No.1897 Sum of 2nd Max
ユーザー 👑 KazunKazun
提出日時 2022-04-08 22:33:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 78,484 KB
最終ジャッジ日時 2023-08-19 01:01:30
合計ジャッジ時間 6,006 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,272 KB
testcase_01 AC 59 ms
71,252 KB
testcase_02 AC 58 ms
71,344 KB
testcase_03 AC 215 ms
78,304 KB
testcase_04 AC 217 ms
78,396 KB
testcase_05 AC 139 ms
76,732 KB
testcase_06 AC 138 ms
77,032 KB
testcase_07 AC 166 ms
77,184 KB
testcase_08 AC 149 ms
77,068 KB
testcase_09 AC 225 ms
78,364 KB
testcase_10 AC 210 ms
78,404 KB
testcase_11 AC 215 ms
78,340 KB
testcase_12 AC 217 ms
78,484 KB
testcase_13 AC 217 ms
78,456 KB
testcase_14 AC 97 ms
77,840 KB
testcase_15 AC 96 ms
77,776 KB
testcase_16 AC 119 ms
77,576 KB
testcase_17 AC 109 ms
77,668 KB
testcase_18 AC 115 ms
77,640 KB
testcase_19 AC 60 ms
71,196 KB
testcase_20 AC 60 ms
71,544 KB
testcase_21 AC 61 ms
71,264 KB
testcase_22 AC 61 ms
71,432 KB
testcase_23 AC 60 ms
71,120 KB
testcase_24 AC 58 ms
71,528 KB
testcase_25 AC 60 ms
71,304 KB
testcase_26 AC 62 ms
71,412 KB
testcase_27 AC 61 ms
71,432 KB
testcase_28 AC 62 ms
71,440 KB
testcase_29 AC 61 ms
71,340 KB
testcase_30 AC 215 ms
78,480 KB
testcase_31 AC 231 ms
78,356 KB
testcase_32 AC 190 ms
77,084 KB
testcase_33 AC 269 ms
78,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())

Mod=998244353
T=[0]*(K+1); U=pow(K,N,Mod)

for k in range(K,0,-1):
    """ 2nd_max(T)>=k iff not (全て k 未満 or ( k 以上がちょうど 1 個, 残りは k 未満))

    """

    T[k]=U-(pow(k-1,N,Mod)+N*(K-k+1)*pow(k-1,N-1,Mod))%Mod

print(sum(T)%Mod)
0