結果

問題 No.1897 Sum of 2nd Max
ユーザー tamatotamato
提出日時 2022-04-08 21:59:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 68,352 KB
最終ジャッジ日時 2024-05-06 07:33:36
合計ジャッジ時間 7,849 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,712 KB
testcase_01 AC 37 ms
51,712 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 402 ms
68,224 KB
testcase_04 AC 414 ms
64,896 KB
testcase_05 AC 215 ms
59,392 KB
testcase_06 AC 217 ms
58,880 KB
testcase_07 AC 271 ms
61,440 KB
testcase_08 AC 233 ms
59,264 KB
testcase_09 AC 408 ms
67,968 KB
testcase_10 AC 379 ms
67,968 KB
testcase_11 AC 387 ms
67,712 KB
testcase_12 AC 402 ms
68,352 KB
testcase_13 AC 391 ms
67,712 KB
testcase_14 AC 128 ms
58,496 KB
testcase_15 AC 125 ms
58,496 KB
testcase_16 AC 174 ms
58,496 KB
testcase_17 AC 151 ms
58,624 KB
testcase_18 AC 176 ms
58,752 KB
testcase_19 AC 37 ms
51,968 KB
testcase_20 AC 36 ms
52,096 KB
testcase_21 AC 36 ms
52,224 KB
testcase_22 AC 37 ms
52,224 KB
testcase_23 AC 35 ms
51,968 KB
testcase_24 AC 36 ms
51,456 KB
testcase_25 AC 37 ms
51,968 KB
testcase_26 AC 35 ms
51,840 KB
testcase_27 AC 40 ms
51,840 KB
testcase_28 AC 35 ms
52,096 KB
testcase_29 AC 36 ms
51,840 KB
testcase_30 AC 421 ms
67,968 KB
testcase_31 AC 430 ms
68,224 KB
testcase_32 AC 329 ms
60,928 KB
testcase_33 AC 473 ms
65,152 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