結果
| 問題 |
No.2568 列辞書順列列
|
| コンテスト | |
| ユーザー |
Pres1dent
|
| 提出日時 | 2023-12-02 16:39:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 664 bytes |
| コンパイル時間 | 3,058 ms |
| コンパイル使用メモリ | 165,560 KB |
| 最終ジャッジ日時 | 2025-02-18 05:35:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 TLE * 1 -- * 22 |
ソースコード
#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;
}
}
Pres1dent