結果
| 問題 | 
                            No.1897 Sum of 2nd Max
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-04-10 17:41:06 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 36 ms / 2,000 ms | 
| コード長 | 427 bytes | 
| コンパイル時間 | 4,151 ms | 
| コンパイル使用メモリ | 232,136 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-14 06:23:07 | 
| 合計ジャッジ時間 | 5,638 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int N,K;cin >> N >> K;
  using mint = modint998244353;
  vector<mint> cnt(K+1);
  mint rp = 0;
  for(int i=1;i<=K;i++){
    cnt[i] += mint(i).pow(N);
    cnt[i] += mint(K-i)*N*mint(i).pow(N-1);
    cnt[i] -= rp;
    rp += cnt[i];
  }
  mint ans = 0;
  for(int i=1;i<=K;i++) ans += i*cnt[i];
  cout << ans.val() << "\n";
}