結果

問題 No.1897 Sum of 2nd Max
ユーザー KazunKazun
提出日時 2022-04-08 22:33:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 77,292 KB
最終ジャッジ日時 2024-11-28 13:18:29
合計ジャッジ時間 5,446 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,976 KB
testcase_01 AC 37 ms
53,316 KB
testcase_02 AC 40 ms
53,252 KB
testcase_03 AC 233 ms
76,824 KB
testcase_04 AC 223 ms
74,448 KB
testcase_05 AC 133 ms
63,324 KB
testcase_06 AC 132 ms
61,352 KB
testcase_07 AC 164 ms
67,516 KB
testcase_08 AC 139 ms
62,644 KB
testcase_09 AC 239 ms
77,116 KB
testcase_10 AC 226 ms
77,156 KB
testcase_11 AC 228 ms
76,996 KB
testcase_12 AC 229 ms
77,000 KB
testcase_13 AC 236 ms
76,808 KB
testcase_14 AC 81 ms
60,668 KB
testcase_15 AC 83 ms
61,260 KB
testcase_16 AC 108 ms
60,552 KB
testcase_17 AC 96 ms
60,992 KB
testcase_18 AC 106 ms
61,244 KB
testcase_19 AC 38 ms
52,756 KB
testcase_20 AC 38 ms
52,148 KB
testcase_21 AC 38 ms
52,468 KB
testcase_22 AC 38 ms
52,980 KB
testcase_23 AC 38 ms
53,572 KB
testcase_24 AC 39 ms
52,520 KB
testcase_25 AC 38 ms
53,436 KB
testcase_26 AC 38 ms
53,048 KB
testcase_27 AC 37 ms
53,556 KB
testcase_28 AC 37 ms
52,616 KB
testcase_29 AC 39 ms
52,796 KB
testcase_30 AC 230 ms
77,268 KB
testcase_31 AC 245 ms
77,292 KB
testcase_32 AC 192 ms
65,784 KB
testcase_33 AC 271 ms
74,560 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