結果

問題 No.1897 Sum of 2nd Max
ユーザー ShirotsumeShirotsume
提出日時 2021-11-20 01:42:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 81,356 KB
最終ジャッジ日時 2024-05-06 06:42:09
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,840 KB
testcase_01 AC 38 ms
51,456 KB
testcase_02 AC 34 ms
51,584 KB
testcase_03 AC 279 ms
80,588 KB
testcase_04 AC 272 ms
81,024 KB
testcase_05 AC 152 ms
64,000 KB
testcase_06 AC 154 ms
59,392 KB
testcase_07 AC 200 ms
70,656 KB
testcase_08 AC 165 ms
64,384 KB
testcase_09 AC 302 ms
80,596 KB
testcase_10 AC 285 ms
80,512 KB
testcase_11 AC 284 ms
80,384 KB
testcase_12 AC 286 ms
80,640 KB
testcase_13 AC 285 ms
80,512 KB
testcase_14 AC 101 ms
60,032 KB
testcase_15 AC 102 ms
60,032 KB
testcase_16 AC 132 ms
60,288 KB
testcase_17 AC 117 ms
60,160 KB
testcase_18 AC 133 ms
60,288 KB
testcase_19 AC 38 ms
52,224 KB
testcase_20 AC 36 ms
51,456 KB
testcase_21 AC 34 ms
51,968 KB
testcase_22 AC 34 ms
51,456 KB
testcase_23 AC 34 ms
51,456 KB
testcase_24 AC 34 ms
51,840 KB
testcase_25 AC 34 ms
51,840 KB
testcase_26 AC 34 ms
51,584 KB
testcase_27 AC 34 ms
52,352 KB
testcase_28 AC 35 ms
52,096 KB
testcase_29 AC 33 ms
51,840 KB
testcase_30 AC 274 ms
80,732 KB
testcase_31 AC 301 ms
80,512 KB
testcase_32 AC 223 ms
68,608 KB
testcase_33 AC 338 ms
81,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, k):
    q = [0] * (k + 10)
    mod = 998244353
    ans = 0
    for i in range(k + 1, 0, -1):
        q[i] = pow(k, n, mod) - pow(i - 1, n, mod) - (k - i + 1) * n * pow(i - 1, n - 1, mod)
        q[i] %= mod
        ans += i * (q[i] - q[i + 1])
        ans %= mod
    return ans

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

print(solve(n, k))
0