結果

問題 No.2568 列辞書順列列
ユーザー Preds1dentPreds1dent
提出日時 2023-12-02 16:39:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 664 bytes
コンパイル時間 4,175 ms
コンパイル使用メモリ 172,072 KB
実行使用メモリ 10,772 KB
最終ジャッジ日時 2023-12-02 16:39:53
合計ジャッジ時間 9,946 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
// S_1 = ((1), (2), ..., (m))
// S_2 = ((1, 1), (1, 2), ..., (m, m))

int main() {
  int n, m, q; cin >> n >> m >> q;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r;
    l--, r--;
    int k = r - l + 1;
    long long ans = 0;
    for (int j = 0; j < k; j++) {
      ans += (a[l + j] - 1) * pow_mod(m, k - j - 1, 998244353);
    }
    cout << (ans + 1) % 998244353 << endl;
  }

}
0