結果

問題 No.1897 Sum of 2nd Max
ユーザー roarisroaris
提出日時 2022-04-22 15:36:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 280 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,644 KB
実行使用メモリ 78,188 KB
最終ジャッジ日時 2023-09-06 01:17:35
合計ジャッジ時間 7,841 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,096 KB
testcase_01 AC 69 ms
70,760 KB
testcase_02 AC 71 ms
70,972 KB
testcase_03 AC 256 ms
78,012 KB
testcase_04 AC 241 ms
77,964 KB
testcase_05 AC 157 ms
76,756 KB
testcase_06 AC 159 ms
76,920 KB
testcase_07 AC 187 ms
77,152 KB
testcase_08 AC 163 ms
76,616 KB
testcase_09 AC 256 ms
78,068 KB
testcase_10 AC 237 ms
78,036 KB
testcase_11 AC 240 ms
78,016 KB
testcase_12 AC 242 ms
78,188 KB
testcase_13 AC 241 ms
78,020 KB
testcase_14 AC 109 ms
77,336 KB
testcase_15 AC 111 ms
77,340 KB
testcase_16 AC 140 ms
77,320 KB
testcase_17 AC 125 ms
77,436 KB
testcase_18 AC 136 ms
77,112 KB
testcase_19 AC 73 ms
71,088 KB
testcase_20 AC 71 ms
70,984 KB
testcase_21 AC 72 ms
71,040 KB
testcase_22 AC 68 ms
71,044 KB
testcase_23 AC 73 ms
71,080 KB
testcase_24 AC 74 ms
71,084 KB
testcase_25 AC 73 ms
71,080 KB
testcase_26 AC 70 ms
71,080 KB
testcase_27 AC 68 ms
71,080 KB
testcase_28 AC 69 ms
70,984 KB
testcase_29 AC 72 ms
70,612 KB
testcase_30 AC 250 ms
78,116 KB
testcase_31 AC 262 ms
78,092 KB
testcase_32 AC 219 ms
76,688 KB
testcase_33 AC 291 ms
77,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
p = [0]*(K+1) # p[i]: second maxがi以下になる個数
MOD = 998244353

for i in range(1, K+1):
    p[i] = (pow(i, N, MOD)+N*(K-i)*pow(i, N-1, MOD))%MOD

ans = 0

for i in range(1, K+1):
    ans += (p[i]-p[i-1])*i%MOD
    ans %= MOD

print(ans)
0