結果

問題 No.1897 Sum of 2nd Max
ユーザー lloyzlloyz
提出日時 2022-04-08 23:36:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 610 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 87,360 KB
実行使用メモリ 76,576 KB
最終ジャッジ日時 2023-08-19 02:09:42
合計ジャッジ時間 10,387 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,080 KB
testcase_01 AC 59 ms
71,476 KB
testcase_02 AC 59 ms
71,556 KB
testcase_03 AC 472 ms
76,436 KB
testcase_04 AC 443 ms
76,348 KB
testcase_05 AC 280 ms
76,308 KB
testcase_06 AC 289 ms
76,396 KB
testcase_07 AC 353 ms
76,168 KB
testcase_08 AC 299 ms
76,396 KB
testcase_09 AC 510 ms
76,492 KB
testcase_10 AC 483 ms
76,452 KB
testcase_11 AC 482 ms
76,452 KB
testcase_12 AC 484 ms
76,200 KB
testcase_13 AC 493 ms
76,056 KB
testcase_14 AC 163 ms
76,124 KB
testcase_15 AC 162 ms
76,100 KB
testcase_16 AC 230 ms
76,420 KB
testcase_17 AC 191 ms
76,380 KB
testcase_18 AC 218 ms
76,112 KB
testcase_19 AC 60 ms
71,560 KB
testcase_20 AC 59 ms
71,088 KB
testcase_21 AC 59 ms
71,172 KB
testcase_22 AC 59 ms
71,400 KB
testcase_23 AC 59 ms
71,564 KB
testcase_24 AC 59 ms
71,524 KB
testcase_25 AC 59 ms
71,200 KB
testcase_26 AC 60 ms
71,384 KB
testcase_27 AC 59 ms
71,084 KB
testcase_28 AC 60 ms
71,476 KB
testcase_29 AC 58 ms
71,412 KB
testcase_30 AC 477 ms
76,316 KB
testcase_31 AC 527 ms
76,440 KB
testcase_32 AC 431 ms
76,576 KB
testcase_33 AC 610 ms
76,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
mod = 998244353

def calc(x):
    num = pow(k, n, mod)
    num -= pow(x - 1, n, mod)
    num %= mod
    num -= ((k - x + 1) * n % mod) * pow(x - 1, n - 1, mod) % mod
    num %= mod
    return num

ans = 0
for i in range(1, k + 1):
    num = calc(i) - calc(i + 1)
    ans += i * num % mod
    ans %= mod
print(ans)
0