結果

問題 No.1897 Sum of 2nd Max
ユーザー 👑 tamatotamato
提出日時 2022-04-08 21:59:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 76,660 KB
最終ジャッジ日時 2023-08-19 00:35:31
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
71,548 KB
testcase_01 AC 56 ms
71,344 KB
testcase_02 AC 57 ms
71,628 KB
testcase_03 AC 419 ms
76,660 KB
testcase_04 AC 429 ms
76,084 KB
testcase_05 AC 230 ms
75,940 KB
testcase_06 AC 236 ms
75,924 KB
testcase_07 AC 302 ms
76,084 KB
testcase_08 AC 244 ms
76,096 KB
testcase_09 AC 416 ms
76,452 KB
testcase_10 AC 390 ms
76,624 KB
testcase_11 AC 396 ms
76,476 KB
testcase_12 AC 396 ms
76,216 KB
testcase_13 AC 405 ms
76,444 KB
testcase_14 AC 144 ms
76,028 KB
testcase_15 AC 142 ms
76,028 KB
testcase_16 AC 192 ms
76,184 KB
testcase_17 AC 169 ms
76,056 KB
testcase_18 AC 186 ms
76,148 KB
testcase_19 AC 63 ms
71,304 KB
testcase_20 AC 58 ms
71,272 KB
testcase_21 AC 57 ms
71,628 KB
testcase_22 AC 58 ms
71,300 KB
testcase_23 AC 59 ms
71,148 KB
testcase_24 AC 57 ms
71,344 KB
testcase_25 AC 56 ms
71,576 KB
testcase_26 AC 57 ms
71,384 KB
testcase_27 AC 57 ms
71,348 KB
testcase_28 AC 59 ms
71,304 KB
testcase_29 AC 59 ms
71,268 KB
testcase_30 AC 409 ms
76,240 KB
testcase_31 AC 427 ms
76,240 KB
testcase_32 AC 348 ms
76,116 KB
testcase_33 AC 503 ms
76,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

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

    ans = 0
    for x in range(1, K+1):
        ans += ((x * N * (K - x))%mod * (pow(x, N - 1, mod) - pow(x - 1, N - 1, mod)))%mod
        ans += (x * (pow(x, N, mod) - pow(x-1, N, mod) - N * pow(x-1, N-1, mod))%mod)%mod
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
0