結果
| 問題 | No.1897 Sum of 2nd Max |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-11-11 13:06:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 299 ms / 2,000 ms |
| コード長 | 286 bytes |
| 記録 | |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 81,152 KB |
| 最終ジャッジ日時 | 2024-09-26 02:43:46 |
| 合計ジャッジ時間 | 5,732 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
N, K = map(int, input().split())
mod = 998244353
ans = 0
KN = pow(K, N, mod)
q = [0] * (K + 5)
for x in range(K, 0, -1):
q[x] = KN - pow(x - 1, N, mod)
q[x] -= (K - x + 1) * N * pow(x - 1, N - 1, mod)
q[x] %= mod
ans += x * (q[x] - q[x+1])
ans %= mod
print(ans)
rlangevin