結果

問題 No.2544 Many RMQ Problems
ユーザー ochiaigawaochiaigawa
提出日時 2023-11-24 22:55:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 3,389 ms
コンパイル使用メモリ 206,192 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-24 22:55:28
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 149 ms
6,676 KB
testcase_04 AC 132 ms
6,676 KB
testcase_05 AC 119 ms
6,676 KB
testcase_06 AC 138 ms
6,676 KB
testcase_07 AC 64 ms
6,676 KB
testcase_08 AC 28 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 148 ms
6,676 KB
testcase_20 AC 149 ms
6,676 KB
testcase_21 AC 149 ms
6,676 KB
testcase_22 AC 150 ms
6,676 KB
testcase_23 AC 149 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 149 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 149 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using mint = atcoder::modint998244353;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);

  /* experiment
  for(int N = 1; N <= 8; N++) {
    cout << N << endl;
    vector<int> perm(N);
    for(int i = 0; i < N; i++) {
      perm[i] = i + 1;
    }
    vector<long long> cnt(N + 1);
    do {
      for(int i = 0; i < N; i++) {
        for(int j = i; j < N; j++) {
          int mn = N + 1;
          for(int k = i; k <= j; k++) {
            mn = min(mn, perm[k]);
          }
          cnt[mn]++;
        }
      }
    } while(next_permutation(perm.begin(), perm.end()));
    for(int i = 1; i <= N; i++) cout << cnt[i] << ' ';
    cout << endl;
  }
  */
  int N, Q;
  cin >> N >> Q;
  mint B = 1;
  for(int i = 1; i <= N; i++) {
    B *= i;
  }
  mint ans = 0;
  for(int i = N; i >= 1; i--) {
    ans += mint(i) * B;
    B = B * (i + 2) / i;
  }
  ans *= (mint(N) * (N + 1) / 2).pow(Q - 1) * Q;
  cout << ans.val() << '\n';
  return 0;
}
0